RE: [xsl] How can I obtain a JSP from a XML and XSL?

Subject: RE: [xsl] How can I obtain a JSP from a XML and XSL?
From: sara.mitchell@xxxxxxxxx
Date: Tue, 12 Nov 2002 14:21:43 -0500
I'm not sure I understand what you want to do, 
so let me tell you what I know how to do: output a
JSP page from an XSLT transformation of some XML input. 

If that is what you want -- the output of a transformation
contains JSP directives, including ones that are not valid 
xml, you can do this using disable-output-escaping (d-o-e)
if your XSLT processor supports this feature. If that's
not what you want, skip the rest of this message.

Normally d-o-e is a bad thing to do. But in this case, it's
the only way and this is what d-o-e is meant for. First, 
make sure that the XSLT engine you are using supports 
d-o-e -- check the documentation.  

Then in your XSLT stylesheet, the output should be either html or
xml like this: 

<xsl:output method="xml" ... /> or <xsl:output method="html" ... />

In the template where you need to output the JSP directive
from your message, do something like this: 

<xsl:template match="some node here">
... whatever else you need to do with this node ...
<xsl:text disable-output-escaping="yes"><![CDATA[<%@ taglib
uri="/s2ktaglib.tld" prefix="s2k" %>]]></xsl:text>
...
</xsl:template> 

What is happening here is that the <![CDATA[ ]]> markup is needed to 
get your JSP directive through the XML parser. The JSP is not 
valid XML and the XML parser will expect XML because of the < and > 
characters. So, CDATA just tells the parser not to expect XML inside 
it and the parser is happy. 

The <xsl:text> element outputs text and the disable-output-escaping="yes"
tells the XSLT engine not to escape characters in XML that would normally
have to be escaped like the < and > in the JSP directive.

Hope this helps, 

Sara Mitchell

> -----Original Message-----
> From: Marcial Atienzar Navarro [mailto:maratna@xxxxxxxxxxxxx]
> Sent: Monday, November 11, 2002 11:30 PM
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: [xsl] How can I obtain a JSP from a XML and XSL?
> 
> 
> Hello everybody,
> 
>  I'm using jstl to parse a xml with a xsl. The scheme is the next:
> 
>   parser.jsp
>       |
>       | (with jstl)
>       |
>   parse the xml with the xsl
>       |
>       |
>   I need to obtain a JSP that containt a jsp tag to compile 
> it. How could I
> include the sentence <%@ taglib uri="/s2ktaglib.tld" 
> prefix="s2k" %> to obtain the 
> jsp and the valour of the tag.
> 
>  A lot of thanks,
> 
>    Marcial Atienzar
> 
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
> 

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread