Reputation: 553
I have one question regarding xsl:for-each
if there are list of code
COMPXXXX COMPXXXX COMPXXXX LAWSXXXX LAWSXXXX
XXXX (are numbers 2383)
and if I just want to display code that starts with COMP,
how should I do this??
I tried to have xsi:course[code='COMP'] but it did not work (of course I guess..)
<xsl:for-each select="xsi:catalogue/xsi:course[code='COMP']">
<xsl:apply-templates select="xsi:code" />
<br />
<xsl:apply-templates select="xsi:title" />
<br />
<xsl:apply-templates select="xsi:year" />
<br />
<xsl:apply-templates select="xsi:science" />
<br />
<xsl:apply-templates select="xsi:area" />
<br />
<xsl:apply-templates select="xsi:subject" />
<br />
<xsl:apply-templates select="xsi:updated" />
<br />
<xsl:apply-templates select="xsi:unit" />
<br />
<xsl:apply-templates select="xsi:description" />
<br />
<xsl:apply-templates select="xsi:outcomes" />
<br />
<xsl:apply-templates select="xsi:incompatibility" />
</xsl:for-each>
Upvotes: 1
Views: 413
Reputation: 243449
Use:
xsi:catalogue/xsi:course[starts-with(code,'COMP')]
Explanation:
Proper use of the standard XPath function starts-with()
Upvotes: 3