Quote:
quote:Describe your problem, rather than your procedural approach to solving it, and we might be able to help you.
|
ok, if to simplify it a lot I have an XML:
Code:
<?xml version="1.0" encoding="windows-1251"?>
<?xml-stylesheet type="text/xsl" href="test_xsl.xsl" indent="yes" encoding="Windows-1251"?>
<root>
<status>
<name>START</name>
<date>1</date>
</status>
<status>
<name>END</name>
<date>3</date>
</status>
<status>
<name>START</name>
<date>5</date>
</status>
</root>
I need to get a new XML with information about latest START date and latest END date. But I need latest END date only in case it is later than latest START date.
So in my case the result would be:
Code:
<?xml version="1.0" encoding="UTF-8" ?>
- <root>
<latest_START>5</latest_START>
<latest_END/>
</root>
END date is empty, because we don't have it after latest START date.
I used XSL to find both latest dates:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="root">
<root>
<latest_START>
<xsl:apply-templates select="status[name='START']">
<xsl:sort select="date" order="descending"/>
</xsl:apply-templates>
</latest_START>
<latest_END>
<xsl:apply-templates select="status[name='END']">
<xsl:sort select="date" order="descending"/>
</xsl:apply-templates>
</latest_END>
</root>
</xsl:template>
<xsl:template match="status">
<xsl:if test="position()=1">
<xsl:value-of select="date"/>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
but in this case the latest END is incorrect.
I wanted to capture latest START date into variable and use it in:
Code:
<xsl:apply-templates select="status[name='END' and date>$last_START_date]">