XML Editor
Sign up for a WebBoard account Sign Up Keyword Search Search More Options... Options
Chat Rooms Chat Help Help News News Log in to WebBoard Log in Not Logged in
Show tree view Topic
Topic Page 1 2 3 4 5 6 7 8 9 Go to previous topicPrev TopicGo to next topicNext Topic
Jerry JanofskySubject: thought I was being clever but I'm not
Author: Jerry Janofsky
Date: 14 Oct 2007 02:36 PM
In my XSLT below, I am using the CDATA section because if I don't then the this XSLT is not a valid XML document (this is where I thought I was being clever). Stylus studio will throw an error because the XML format is improper; <fo:table-row> is not followed by </fo:table-row> before the </xsl:if>. By using the CDATA section, the XSLT becomes valid XML and the XSL:FO document that is generated will also be valid. I am disabling output escaping because if I don't, the '<' and '>' in fo:table-row will be escaped and the RenderX XSL:FO processor won't process it properly. When I execute this with SAXON 8 in stylus studio everything is fine. However, my production environment uses SAXON 8 with something called COCOON. I end up with the following problomatic XSL:FO document section that I can't fix:

<?javax.xml.transform.disable-output-escaping ?>
<?javax.xml.transform.enable-output-escaping ?>

My real problem is that I don't know how do create my XSL:FO document without using the CDATA trick I have shown below.

Does anyone see how to make this section of XSLT be valid XML without using the CDATA section?

<xsl:for-each select="current-group()">

<xsl:if test="(position() mod 3) = 1">
<xsl:text disable-output-escaping="yes">

<fo:table-cell border="0pt solid black">

<xsl:if test="((position() mod 3) = 0) or (position() = last())"> <xsl:text disable-output-escaping="yes">


Tony LavinioSubject: thought I was being clever but I'm not
Author: Tony Lavinio
Date: 15 Oct 2007 12:12 AM
First, never use disable-output-escaping. It only works properly
when each stage in the serialization understands it, and many
environments such as Cocoon don't, because they do different things
with the data so that at each step they need 'real' XML.

The proper way to handle situations like this is to ALWAYS remember
that XML is not composed of content with tags interspersed, but instead
is composed of elements that contain content. So you always want your
<> and </> to be balanced.

Often it means doing things like this:

<xsl:when test="...">
<xsl:when test="...">

Each case would then be completely valid XML.

Another method might be to process three rows at a time, and
just using <xsl:if>'s to wrap the 2nd and 3rd to make sure you
don't run off the end of the list.

Hope one of these suggestions helps.

Topic Page 1 2 3 4 5 6 7 8 9 Go to previous topicPrev TopicGo to next topicNext Topic
Download A Free Trial of Stylus Studio 6 XML Professional Edition Today! Powered by Stylus Studio, the world's leading XML IDE for XML, XSLT, XQuery, XML Schema, DTD, XPath, WSDL, XHTML, SQL/XML, and XML Mapping!  

Log In Options

Site Map | Privacy Policy | Terms of Use | Trademarks
Stylus Scoop XML Newsletter:
W3C Member
Stylus Studio® and DataDirect XQuery ™are from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2016 All Rights Reserved.