xsl-list
[Top] [All Lists]

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

2008-02-11 09:07:15
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/ 



--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--