Subject: [xsl] Identifying sets of child elements that meet a certain condition From: "Mark Peters" <flickrmeister@xxxxxxxxx> Date: Mon, 11 Feb 2008 10:31:34 -0500 |
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
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] On the prowell, Karl Stubsjoen | Thread | RE: [xsl] Identifying sets of child, Michael Kay |
Re: [xsl] result-document error, R. Neville | Date | RE: [xsl] Identifying sets of child, Michael Kay |
Month |