Subject: Re: choose on element content. From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx> Date: Tue, 24 Aug 1999 10:43:18 -0400 |
given <INDI ID='I001'> <NAME>John Derek <S>Montalt (Moult)</S></NAME> <SEX>M</SEX>
I need conditional processing, dependent on the sex of the NAMEd person.
I'm getting a syntax error with
<xsl:template match="INDI"> <xsl:choose> <xsl:when test="[string(SEX)='M']"> ^^^^^^^^^^^^^^^^^^ syntax error.^^^^^^^^^^^^^
T:\FTEMP>type test.xml <?xml version="1.0"?> <test> <person><sex>M</sex><name>John</name></person> <person><sex>F</sex><name>Jane</name></person> </test> T:\FTEMP>type test.xsl <?xml version="1.0"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/XSL/Transform/1.0">
<xsl:template match="/test"> <xsl:for-each select="person"> <xsl:choose> <xsl:when test="sex='M'">
Male: </xsl:when> <xsl:when test="sex='F'">
Female: </xsl:when> <xsl:otherwise>
Who knows?: </xsl:otherwise> </xsl:choose> <xsl:value-of select="name"/> </xsl:for-each> </xsl:template>
T:\FTEMP>call xsl test.xml test.xsl test.txt T:\FTEMP>type test.txt
Male: John Female: Jane T:\FTEMP>
-- G. Ken Holman mailto:gkholman@xxxxxxxxxxxxxxxxxxxx Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/ Box 266, Kars, Ontario CANADA K0A-2E0 +1(613)489-0999 (Fax:-0995) Website: XSL/XML/DSSSL/SGML services, training, libraries, products. Practical Transformation Using XSLT and XPath ISBN 1-894049-01-2 Next instructor-led training: MT'99 1999-12-05/06
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
choose on element content., DPawson | Thread | RE: choose on element content., Harbarth, Juliane |
RE: key and document(), Kay Michael | Date | SAXON question: Propagator.build(In, Zsolt Czinkos |
Month |