Re: [xslt] xsltproc docbook and user.header.navigation handling



On Sun, 2003-10-05 at 13:11, Jim Crafton wrote:
> I have a bunch of docbook files, plus a custom xsl stylesheet, and a 
> makefile that is used to build the whole thing. In the xsl sheet i 
> override the
> <xsl:template name="user.header.navigation"> template. In this I have 
> some header html wrapped in a CDATA tag. This all used to output 
> flawlessly until I upgraded my cygwin install (which I beleive also 
> upgraded xsltproc). Now the output has all the "<" characters 
> transformed to "&lt;" and so on. Looking on google and this mailing list 
> it appears that this is a feature that was added per the xml spec. If 
> so, how can I get the output to resemble html again with the "<" 
> characters intact?
> 
> This is a fragment of what I have in the stylsheet that used to work:
> <xsl:template name="user.header.navigation">   
>     <![CDATA[   
> <table width="100%" border="0" cellpadding="0" cellspacing="0">
>  <tr>
>   <td class="logoCell" width="400" height="80" valign="top">
>    <table width="400" border="0" cellpadding="0" cellspacing="0">
>     <tr>
> ......rest clipped
> ]]>
> </xsl:template>
> 
> I used to get output like:
> 
> <table width="100%" border="0" cellpadding="0" cellspacing="0">
>  <tr>
>   <td class="logoCell" width="400" height="80" valign="top">
>    <table width="400" border="0" cellpadding="0" cellspacing="0">
>     <tr>
> and so on.
> 
> Now I get :
> 
> &lt;table width=&quot;100%&quot; border=&quot;0&quot; cellpadding=&quot;0&quot;
> cellspacing=&quot;0&quot;&gt;
>  &lt;tr&gt;
> 
>   &lt;td class=&quot;logoCell&quot; width=&quot;400&quot; height=&quot;80&quot;
> valign=&quot;top&quot;&gt;
>    &lt;table width=&quot;400&quot; border=&quot;0&quot; cellpadding=&quot;0&quot;
> cellspacing=&quot;0&quot;&gt;
> 
>     &lt;tr&gt;
> 
> I didn't see (or understand, perhaps) how to solve this, apologies if this has
> been answered before.

I don't know why this ever worked, but it's wrong.  You can't put XML in
a CDATA and expect to to get actual XML output.  A CDATA is logically
equivalent to normal text.  It's just a way for humans to avoid having
to escape lots of characters.

What you want is to disable output escaping on a text node.  You can use
the disable-output-escaping attributes on xsl:text for this.  So:

<xsl:text disable-output-escaping="yes">
<![CDATA[<table>]>
</xsl:text>

And now I have to tell you never to use disable-output-escaping.  It's a
horrible hack, and it's very fragile.  I presume that you're intending
to have some unbalanced tags in user.header.navigation, and that you're
balancing them out in user.footer.navigation.  The clean and correct way
of handling this is to override chunk-element-content (assuming this is
Norm's XSLT).

--
Shaun






[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]