This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Please help (XSLT)
- To: XSL-List at mulberrytech dot com
- Subject: Please help (XSLT)
- From: Cheun N Chong <cnc99r at ecs dot soton dot ac dot uk>
- Date: Thu, 1 Jun 2000 16:29:25 +0100 (BST)
- Reply-To: xsl-list at mulberrytech dot com
Dear all,
I am confused about XSLT again. I have the following XML codes:
<TICKETS>
<TICKET>
<FEATURES>
<NUMBER>1</NUMBER>
<EXPIRE>2 May 2000</EXPIRE>
</FEATURES>
<CONDITION>valid</CONDITION>
</TICKET>
<TICKET>
<FEATURES>
<NUMBER>2</NUMBER>
<EXPIRE>10 May 2000</EXPIRE>
</FEATURES>
<CONDITION>valid</CONDITION>
</TICKET>
<TICKET>
<FEATURES>
<NUMBER>5</NUMBER>
<EXPIRE>5 May 2000</EXPIRE>
</FEATURES>
<CONDITION>valid</CONDITION>
</TICKET>
</TICKETS>
Assume the ticket thing in the XML is lottery tickes.
I have created an XSL file in order to:
1. read in the today's date and compare to the <EXPIRE>
and set the <CONDITION>
2. compare the <NUMBER> with the input winning number
and set the <CONDITION>
and transform it into a new XML document, for example out.xml.
(I am using LotusXSL and XML4J from alphaWorks of IBM)
I have created the following XSL codes:
...
<xsl:param name="expire" />
<xsl:param name="win" />
<xsl:template name="readExp">
<xsl:variable
name="expireDay" select="format-number(number(substring-before($expire,'
')),'00')" />
<xsl:variable
name="expireMonth" select="document('')//fo:month[@name=substring-before(substring-after($expire,'
'),' ')]/@num" />
<xsl:variable
name="expireYear" select="substring-after(substring-after($expire,' '),'
')" />
<xsl:value-of
select="number(concat($expireYear,$expireMonth,$expireDay))" />
</xsl:template>
<xsl:template match="TICKETS">
<xsl:element name="TICKETS">
<xsl:apply-templates select="TICKET" />
</xsl:element>
</xsl:template>
<xsl:template match="FEATURES">
<xsl:element name="FEATURES">
<xsl:apply-templates select="NUMBER" />
<xsl:apply-templates select="EXPIRE" />
</xsl:element>
</xsl:template>
<xsl:template match="CONDITION">
...
</xsl:template>
At the CONDITION, when I tried this:
<xsl:value-of select="//EXPIRE" />
It only print out the first TICKET's EXPIRE value which is "2 May
2000". Please help me. Even a small hint is much appreciated. Thousand
thanks.
Best regards,
Cheun Ngen CHONG
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list