[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Identifying sets of child elements that meet a certain
Hi Everyone, In the following XML document, I'm trying to identify the component nodes that do not contain an attribute with the name "a." In the example, the only component that meets this criterion is "3." <?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> I thought I could construct this transformation using a variable and have read the articles on variables on the list FAQ. But the variables I've constructed either identify any component node that contains AT LEAST ONE attribute that is not "a" (in other words, the entire list of components) rather than those components that do not contain ANY instance of "a" (component 3). Or, they identify no components at all. Here's one example: <xsl:template match="/"> <xsl:variable name="attributename" select="//data/component /attributeList/attribute"/> <topic> <ul> <xsl:for-each select="$attributename[@name!='a']"> <xsl:sort select="@name"/> <xsl:choose> <xsl:when test="public='N'"/> <xsl:otherwise> <li> <xsl:value-of select="../../../@name"/> </li> </xsl:otherwise> </xsl:choose> </xsl:for-each> </ul> </topic> </topic> </xsl:template> The result I'm trying for is as follows: <topic> <ul> <li>3</li> </ul> </topic> Any idea what I'm doing wrong? Thanks, Mark -- Mark Peters Senior Technical Writer Saba Software
|
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
|