hi
i want to print the text based on the "code" param
my xml:
<?xml version="1.0" encoding="UTF-8"?>
<root>
<p>
<subject topic="1">geography</subje
ct>
</p>
<p>
<text> g1 </text>
</p>
<p>
<text> g2 </text>
</p>
<p>
<text> g3 </text>
</p>
<p>
<text> g4 </text>
</p>
<p>
<text> g5 </text>
</p>
<p>
<subject topic="2">history</subject
>
</p>
<p>
<text> h1 </text>
</p>
<p>
<text> h2 </text>
</p>
<p>
<text> h3 </text>
</p>
<p>
<text> h4 </text>
</p>
<p>
<subject topic="3">Business</subjec
t>
</p>
<p>
<text> b1 </text>
</p>
<p>
<text>b2 </text>
</p>
<p>
<text> b3 </text>
</p>
<p>
<text> b4 </text>
</p>
</root>
xsl:::::::::::::::
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="
http://www.w3.org/1999/XSL/Transform" xmlns:fo="
http://www.w3.org/1999/XSL/Format">
<xsl:output indent="yes" encoding="UTF-8" />
<xsl:param name="code">2</xsl:param>
<xsl:template match="/">
<subject>
<xsl:attribute name="code"><xsl:value-of select="$code"/></xsl:attr
ibute>
<xsl:for-each select="following::p[subje
ct/@topic = {$code}]"> <!-- problem only in this XPATH expression- -->
<xsl:if test="not(subject)">
<text>
<xsl:value-of select="."/>
</text>
</xsl:if>
</xsl:for-each>
</subject>
</xsl:template>
</xsl:stylesheet>
the result should look like: (based on the param "code",the text should be displayed)
as i am passing param "code" value "2",
it should print as:
<subject code="2">
<text>h1</text>
<text>h2</text>
<text>h3</text>
<text>h4</text>
</subject>
if i pass param "code" value "1",
<subject code="2">
<text>g1</text>
<text>g2</text>
<text>g3</text>
<text>g4</text>
<text>g5</text>
</subject>
Thanks for your reply,
regards,
Start Free Trial