[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

Subject: Identifying sets of child elements that meet a certain condition
From: "Mark Peters" <flickrmeister@xxxxxxxxx>
Date: Mon, 11 Feb 2008 10:31:34 -0500
 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

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.