|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Please help (XSLT)
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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








