RE: [xsl] Identifying sets of child elements that meet a certain condition

Subject: RE: [xsl] Identifying sets of child elements that meet a certain condition
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Mon, 11 Feb 2008 16:06:42 -0000
It works for me.

Source:

<?xml version="1.0" encoding="UTF-8"?>
<data>
    <component name="1">
        <attributeList>
            <attribute name="a"/>
             <attribute name="b"/>
            <attribute name="c"/>
        </attributeList>
    </component>
    <component name="2">
        <attributeList>
             <attribute name="a"/>
            <attribute name="e"/>
            <attribute name="f"/>
        </attributeList>
    </component>
    <component name="3">
         <attributeList>
            <attribute name="g"/>
            <attribute name="h"/>
            <attribute name="i"/>
        </attributeList>
     </component>
</data>

Stylesheet:

<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";> 
<xsl:output method="xml" indent="no" encoding="UTF-8"/>

<xsl:template match="/">
 <topic>
   <ul>
     <xsl:for-each
select="/data/component[not(attributeList/attribute/@name='a')]">
        <xsl:sort select="@name"/>
            <li>
                <xsl:value-of select="@name"/>
            </li>
     </xsl:for-each>
   </ul>
 </topic>
</xsl:template>

</xsl:stylesheet>

Output:

<?xml version="1.0" encoding="UTF-8"?><topic><ul><li>3</li></ul></topic>

Michael Kay
http://www.saxonica.com/ 

Current Thread