Re: [xsl] transforming from xml to JSF (java server faces)

Subject: Re: [xsl] transforming from xml to JSF (java server faces)
From: George Cristian Bina <george@xxxxxxxxxxxxx>
Date: Thu, 18 May 2006 10:10:52 +0300
Hi John,

If you use the text output method then you need to emit the tags as text to the output that means you need to escape < to &lt; and instead of <html> for instance write &lt;html>.

In XSLT 2.0 you can use character maps, for instance

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl=""; version="2.0">
<xsl:character-map name="percentAt">
<xsl:output-character character="#" string="&lt;%"/>
<xsl:output-character character=">" string=">"/>
<xsl:output method="xml" use-character-maps="percentAt"/>
<xsl:template match="/">
#@ taglib uri=""; prefix="h" %>

will give:

<?xml version="1.0" encoding="UTF-8"?>
<%@ taglib uri=""; prefix="h" %>

Of course you can emit that to the output if you use disable output escaping in XSLT 1.0, but that is not recommended in general, only as the last possible solution:

<xsl:text disable-output-escaping="yes">&lt;%@ taglib uri=""; prefix="h" %></xsl:text>

Best Regards,
George Cristian Bina
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger

John Burgess wrote:
I'm trying to transform an XML file that describes a database schema into a set of jsf files to display the data.
The problem I have is with the initial
<%@ taglib uri=""; prefix="h" %>
tag and others like it.

I've put the lines in a CDATA section so they can exist in the stylesheet but if I set the output type to html then I get
&gt; %@ taglib uri=""; prefix="h" %&lt;
which is no good.

If I use output method text then subsequent <html> and all other tags are quietly omitted.

If I use output method xml then I get the same as html.

How should I deal with this?

Current Thread