CDATA in XML element v1



I have read through a lot of questions already and actually I have what I need but not with the 'for me' correct StyleSheet version. This is my raw XML file:



<document>
<items>
<item id="docScanner" group="0">
<value>docScannerValue</value>
</item>
<item id="docSubject" group="0">
<value>docSubjectValue</value>
</item>
<item id="docAfdeling" group="0">
<value>docAfdelingValue</value>
</item>
<item id="docIdentifier" group="1">
<value>docIdentifierValue</value>
</item>
<item id="docNewVersion" group="1">
<value>docNewVersionValue</value>
</item>
<item id="docFileName" group="1">
<value>docFileNameValue</value>
</item>
</items>


This is the XSLT file:



<xsl:output method="xml" version="1.0" encoding="iso-8859-1"
indent="yes" />

<xsl:template match="/">
<document>
<xsl:for-each select="document/items/item[@group = 0]">
<xsl:element name="{@id}">
<xsl:value-of select="value" />
</xsl:element>
</xsl:for-each>
<xsl:for-each select="document/items/item[@group = 1]">
<xsl:element name="{@id}">
<xsl:text disable-output-escaping="yes"> &lt;![CDATA[ </xsl:text>
<xsl:value-of select="value" />
<xsl:text disable-output-escaping="yes"> ]]&gt; </xsl:text>
</xsl:element>
</xsl:for-each>
</document>
</xsl:template>


this is the output XML I have with version 2.0



<document>
<docScanner>docScannerValue</docScanner>
<docSubject>docSubjectValue</docSubject>
<docAfdeling>docAfdelingValue</docAfdeling>
<docIdentifier>
<![CDATA[ docIdentifierValue ]]>
</docIdentifier>
<docNewVersion>
<![CDATA[ docNewVersionValue ]]>
</docNewVersion>
<docFileName>
<![CDATA[ docFileNameValue ]]>
</docFileName>


Now the question.....what do I have to change in the XSLT file to ale this work in StyleSheet version 1.0?


No comments:

Post a Comment