You are viewing a plain text version of this content. The canonical link for it is here.
Posted to taglibs-dev@jakarta.apache.org by Pierre Delisle <pi...@sun.com> on 2001/02/18 19:25:52 UTC

[PROPOSAL] iotransformer tag library

This is a proposal for a new tag library, tentatively named
iotransformer (I know, I know, the name is not that great... I'm open 
to suggestions :-))

I'd like to make this tag library available under the jakarta-taglibs
project. Let me know what you guys think...

Thanks,

    -- Pierre

---------------------------------------------------------------------------
1. BACKGROUND

Something that often comes up when designing a tag library is the
need to support a variety of input sources and/or output sinks.

For example, the xsl tag library supports inline, bean, as well 
as file input sources, while ouput is always inline. There is 
a substantial amount of code in that tag library to support
this functionality (more sources/sinks are supported via 
the import and export tags). It would be nice to encapsulate all
this functionality in a class library to allow its reuse by any 
tag developer.

Moreover, the generic ability to "connect" any type of input source
to any type of output sink is often requested and would be a valuable
tablib addition.

For example:

- As seen on the struts-user mailing list:
  "Is there a tag (in struts or elsewhere) that will evaluate its body into
   a String that can be squirreled away for later use?"

- As seen on the tomcat-users mailing list:
  "Is it possible to redirect the output of a
   specific JSP or servlet to a file/buffer while the
   tomcat server is running."

- as seen on the taglibs-dev mailing list:
  "... but I was wondering if there is already a way to do the 
  following things:
          - pass parameters to a stylesheet 
          - pass the results of one transformation to another (chaining) 
          - have the xml input be a URL instead of a local file name 
            (so I could get data from MS SQL2K directly)"

---------------------------------------------------------------------------
2. PROPOSAL

This is a proposal for a generic "I/O Transformer" tag/class library
(again, suggestions for a better name are more than welcome).

Its goal is to provide a generic mechanism by which a variety of 
input sources can be copied to a variety of output sinks, with
an optional transformation applied on the input source before
it is copied over to the output sink.

While the tag library is useful by itself, it has been designed
so that the I/O Transformation capabilities are also available as
a class library. Tag designers therefore do not have to reinvent
the wheel when in need of support for various input sources
and output sinks.

More details can be found below.

A series of sample JSP pages have been written to "test/get-the-feel-for"
the 'iotransformer' tag library. The 'examples' web-application currently 
runs at the following URL:

http://delisle.www1.kc.aoindustries.com:1163/iotransformer-taglib-examples

---------------------------------------------------------------------------
3. SYNTAX

   <x:iot [inSpec] [transformSpec] [outSpec]/>

   where:  inSpec ::= 
                    inBean=beanSpec | 
                    inFile="filePath" | 
                    inURL="url"
           transformSpec ::= 
                    transformBean=beanSpec | 
                    transformURL="url"
           outSpec ::= 
                    outBean=beanSpec | 
                    outFile="filePath" | 
                    outURL="url"

           beanSPec ::= [scope.]name[.property]

As can be seen from the syntax above, the following 'types' are
supported for sources/sinks/transforms:

INLINE
    in    if the in attribute is not specified in the tag,
          input comes from the tag's body content
    out   if the out attribute is not specified in the tag,
          output goes into the tag's enclosing writer.
    transform
          if the transform attribute is not specified, input
          is simply copied to output.
BEAN
    A Java object (bean) with or without scope and/or property specified.
    Specify the name of the object as it appears in pageContext. 
        e.g. xsltTransform
    The following notation can be used to specify scope and property
        scope.bean.property
        e.g. application.xslTransform.styleSheetWriter
FILE
    File path can be specified either as absolute, or relative
    to the web application context
        e.g. [webbapp relative]  /generated/customers.html
             [absolute]          d:\tmp\samples

URL
    A URL that can be either 'local' (i.e. a relative URL within the 
    current web application) or 'external'.
        e.g. [local]     /jsp/Customers.jsp  
             [external]  http://acme.com/Customers.jsp

---------------------------------------------------------------------------
4. TRANSFORMATION

If a transformation is specified as a 'bean' (or property on a bean), 
the resulting object must implement the following interface:

  interface Transform {
      public void transform(java.io.Reader input, java.io.Writer output) 
          thows JspException;
  }

If the transform is a URL, input comes from the request,
and output goes to the response.

If no transformation is specified, the input source is simply copied 
over to the output sink
---------------------------------------------------------------------------

Re: [PROPOSAL] iotransformer tag library

Posted by Incze Lajos <in...@mail.matav.hu>.
Pierre Delisle wrote:
> This is a proposal for a new tag library, tentatively named
> iotransformer (I know, I know, the name is not that great... I'm open
> to suggestions :-))
>
> I'd like to make this tag library available under the jakarta-taglibs
> project. Let me know what you guys think...
>

Maybe I am a bit short of fantasy - but what does it do? (Pointers are
also welcomed if I missed something in the email hurricane).      incze

Re: [PROPOSAL] iotransformer tag library

Posted by "Craig R. McClanahan" <Cr...@eng.sun.com>.
Pierre Delisle wrote:

> This is a proposal for a new tag library, tentatively named
> iotransformer (I know, I know, the name is not that great... I'm open
> to suggestions :-))
>
> I'd like to make this tag library available under the jakarta-taglibs
> project. Let me know what you guys think...
>

+1

I've seen some of the early ideas for uses of these tags -- they are awesome.

>
> Thanks,
>
>     -- Pierre
>

Craig McClanahan



Re: [PROPOSAL] iotransformer tag library

Posted by horwat <Ju...@eng.sun.com>.
+1 on adding the IOTransformer taglib.

Justy

----- Original Message ----- 

> This is a proposal for a new tag library, tentatively named
> iotransformer (I know, I know, the name is not that great... I'm open 
> to suggestions :-))
> 
> I'd like to make this tag library available under the jakarta-taglibs
> project. Let me know what you guys think...
> 
> Thanks,
> 
>     -- Pierre