Altova Mailing List Archives>Archive Index >microsoft.public.xsl Archive Home >Recent entries >Thread Prev - Making Specific Node the last one when it exists in XML? [Thread Next] Re: Making Specific Node the last one when it exists in XML?To: NULL Date: 6/1/2007 9:58:00 AM
you shouldn't better use <xsl:for-each>, in most cases it's terrible
construction. instead of it, use <xsl:apply-templates>:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" encoding="UTF-8" indent="yes"/>
<xsl:template match="/*">
<occupationCategories>
<xsl:apply-templates select="Table/Occp_cat">
<xsl:sort select="." data-type="number"/>
</xsl:apply-templates>
</occupationCategories>
</xsl:template>
<xsl:template match="Occp_cat">
<xsl:param name="id" select="./text()"/>
<xsl:if test="not(preceding::Occp_cat[.=$id])">
<category ID="{$id}">
<desc><xsl:value-of select="../occp_cat_desc"/></desc>
<xsl:apply-templates select="/*/Table[Occp_cat[.=$id]]/Occp_ID">
<xsl:sort select="." data-type="number"/>
</xsl:apply-templates>
</category>
</xsl:if>
</xsl:template>
<xsl:template match="Occp_ID">
<occupation ID="{.}"><xsl:value-of select="../Occp_Desc"/></occupation>
</xsl:template>
</xsl:stylesheet>
--
td
www.paranoja.org
| ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
