manasnair
07-28-2009, 11:16 AM
Hi, I am using an XML and the following is a small snippet from it:
<Field name="summary">
<Text highlighted="0">A</Text >
<Text highlighted="1">B</Text >
<Text highlighted="0">C</Text >
<Cut />
<Text highlighted="0">D</Text >
<Text highlighted="1">E</Text >
<Text highlighted="0">F</Text >
<Cut />
</Field>
I am using an XSL to convert it into another xml.
I need the strcuture as:
<Result>
<set></set>
</Result>
There should be as many <set> elements in the result as there are <Cut> elements in the source. ie.
The result should look like:
<Result>
<set>ABC</set>
<set>DEF</set>
</Result>
The <Cut> element should act as the separator. The <Text> elements before and after the <Cut> element should be seggragated and shown.
Here is the snippet of the xsl that i used...
<xsl:if test="@name='summary'">
<S>
<xsl:for-each select="*">
<xsl:choose>
<xsl:when test="local-name()='Text'">
<xsl:if test="@highlighted='0'">
<xsl:value-of select="."/>
</xsl:if>
<xsl:if test="@highlighted='1'">
<xsl:text disable-output-escaping="no"><b></xsl:text>
<xsl:value-of select="."/>
<xsl:text disable-output-escaping="no"></b></xsl:text>
</xsl:if>
</xsl:when>
<xsl:otherwise>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</S>
</xsl:if>
Please help.
Thanks a lot in advance.
Manas
<Field name="summary">
<Text highlighted="0">A</Text >
<Text highlighted="1">B</Text >
<Text highlighted="0">C</Text >
<Cut />
<Text highlighted="0">D</Text >
<Text highlighted="1">E</Text >
<Text highlighted="0">F</Text >
<Cut />
</Field>
I am using an XSL to convert it into another xml.
I need the strcuture as:
<Result>
<set></set>
</Result>
There should be as many <set> elements in the result as there are <Cut> elements in the source. ie.
The result should look like:
<Result>
<set>ABC</set>
<set>DEF</set>
</Result>
The <Cut> element should act as the separator. The <Text> elements before and after the <Cut> element should be seggragated and shown.
Here is the snippet of the xsl that i used...
<xsl:if test="@name='summary'">
<S>
<xsl:for-each select="*">
<xsl:choose>
<xsl:when test="local-name()='Text'">
<xsl:if test="@highlighted='0'">
<xsl:value-of select="."/>
</xsl:if>
<xsl:if test="@highlighted='1'">
<xsl:text disable-output-escaping="no"><b></xsl:text>
<xsl:value-of select="."/>
<xsl:text disable-output-escaping="no"></b></xsl:text>
</xsl:if>
</xsl:when>
<xsl:otherwise>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</S>
</xsl:if>
Please help.
Thanks a lot in advance.
Manas