[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

XPath expression confusion

Subject: XPath expression confusion
From: cknell@xxxxxxxxxx
Date: Thu, 12 Jan 2006 16:48:31 -0500
 XPath expression confusion
I have two files structured like this:

File A
-------
<requirements>
  <requirement>
    <number />
      <requirement>
        <number />
        And so on to an arbitrary depth
      </requirement>
  </requirement>
</requirements>

File B
-------
<system>
  <components>
    <component>
      <requirement number="" />
      <requirement number="" />
      <requirement number="" />
    </component>
  </components>
</system>

There will be an arbitrary number of components, each with an arbitrary number of requirements.

My goal is to produce a document containing all the requirement/number elements from File A that don't have a matching requirement/@number in File B.

My unsuccessful approach is represented in this stylesheet fragment:

<xsl:variable name="all-reqs" select="document('requirements.xml')/requirements//requirement/number" />

  <xsl:template match="/">
    <un-assigned-reqs>
      <xsl:for-each select="$all-reqs">
        <xsl:choose>
          <xsl:when test="/system/components/component/requirement/@number = ." />
          <xsl:otherwise>
            <requirement><xsl:value-of select="." /></requirement>
          </xsl:otherwise>
        </xsl:choose>
      </xsl:for-each>
    </un-assigned-reqs>
  </xsl:template>

It was my belief that the XPath expression in the test would search all the number attribute values in the document for a value that matched the value of the current iteration of the loop.
Instead, it seems that there are no matches, as I get one element output for each iteration of the loop.

Can someone point out where I'm going wrong?

Thanks.

-- 
Charles Knell
cknell@xxxxxxxxxx - email

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.