jakarta-taglibs-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "James Strachan" <james_strac...@yahoo.co.uk>
Subject Re: Adding URIResolver functionality to XTags StyleTag
Date Wed, 26 Sep 2001 07:54:31 GMT
Hi Brian

Sorry for the delay getting back to you, I've been on a short vacation and
it took a while to catch up.

Great idea, using a URIResolver. I've applied your patch, its now in CVS and
should make the next nightly build.

Thanks!

James
----- Original Message -----
From: "Brian Devries" <bdevries@intraware.com>
To: <taglibs-dev@jakarta.apache.org>
Sent: Friday, September 21, 2001 10:01 PM
Subject: Adding URIResolver functionality to XTags StyleTag


> I have run into a probelm using the style tag when trying to use
> includes/imports. I would like to suggest that the StyleTag from xtags
> configure the xslt transformer so that it resolves all included and
> imported stylesheets in the same way the tag resolves a URI, for
> example, through a URL, a relative URL, or a resource.
>
> Here's the code I've added to my version of xtags:
>
>     public int doEndTag() throws JspException {
>         if ( xml == null || xsl == null ) {
>             throw new JspException( "Must specify both XML and an XSLT
> to style" );
>         }
>
>         // Prepare an input source for the data
>         Source data = getSource(xml);
>
>         // Prepare an input source for the stylesheet
>         Source style = getSource(xsl);
>
>         // Prepare an output source for the outputs
>         Result result = getResult();
>
>         // Use JAXP to perform the stylesheet
>         try {
>             TransformerFactory factory =
> TransformerFactory.newInstance();
>             factory.setURIResolver(new URIResolver() {
>
>                 public Source resolve(String href, String base)
>                    throws TransformerException {
>                     try {
>                         return getSource(href);
>                     }
>                     catch(javax.servlet.jsp.JspException e) {
>                         return null;
>                     }
>                 }
>
>             });
>             Transformer transformer = factory.newTransformer(style);
>             configure(transformer);
>             transformer.transform( data, result );
>             if ( stringWriter != null ) {
>                 pageContext.getOut().write( stringWriter.toString() );
>             }
>         }
>         catch (TransformerException e) {
>             handleException(e);
>         }
>         catch (IOException e) {
>             handleException(e);
>         }
>         finally {
>             stringWriter = null;
>         }
>     return EVAL_PAGE;
>     }
>
> -Brian De Vries
>
> --
> Brian De Vries  --  Sr. Software Engineer
> mailto:bdevries@intraware.com   http://www.intraware.com
> Voice: 925.253.6516             Fax: 925.253.4542
> -------------------------------------------------------
> Intraware...Control Your Technology
>


_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com


Mime
View raw message