Altova Mailing List Archives>Archive Index >microsoft.public.xsl Archive Home >Recent entries >Thread Prev - Re: Help with XSLT please [Thread Next] Re: Help with XSLT pleaseTo: NULL Date: 6/17/2008 1:12:00 PM
KP wrote:
> Sorry I made a small mistake in the XML - it should have been:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <document>
> <index><![CDATA[<div class="index">]]>
> <partref/><partref/><![CDATA[</div>]]>
> </index>
> <part>
> Part1
> </part>
> <part>
> Part2
> </part>
> </document>
>
> The XSL example almost does what I want but I need the CDATA elements
> to be taken from the XML and not "hard-coded" into the XSL. This is a
> simplification of a much larger XML/XSL but demonstrates the simple
> problem I am trying to solve.
You should fix the input XML as otherwise the problem is not so simple
to solve, you need disable-output-escaping:
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:output method="html"/>
<xsl:template match="/document">
<xsl:apply-templates select="index/node()"/>
</xsl:template>
<xsl:template match="index/text()">
<xsl:value-of select="." disable-output-escaping="yes"/>
</xsl:template>
<xsl:template match="index/partref">
<xsl:value-of
select="normalize-space(../../part[count(current()/preceding-sibling::partref)
+ 1])"/>
</xsl:template>
</xsl:stylesheet>
Note that disable-output-escaping is an optional serialization feature
meaning it is not supported by all XSLT processors in all scenarios.
Mozilla/Firefox for instance does not support it as it does not
serialize the result tree.
--
Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
| ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
