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

xsl:for-each...iteration question

Subject: xsl:for-each...iteration question
From: "Paul Coletti" <pcoletti@xxxxxxxxxx>
Date: Tue, 19 Apr 2005 18:19:29 +0200
paul coletti
This has been answered before I'm sure but doing a relevant search in the
archives is tricky.

I've an input doc containing a number of modify-attr elements
  <modify-attr attr-name = "abc"/>
  <modify-attr attr-name = "123"/>
  <modify-attr attr-name = "789"/>

I have another document containing a list of prohibited attributes.

I want to iterate over my input doc and copy all those modify-attr elements
that are NOT in the exclude list to the output.

<xsl:template match="modify/modify-attr">
  <xsl:variable name="currentAttr" select="@attr-name"/>
  <xsl:variable name="currentNode" select="."/>

  <xsl:for-each select="document('excludedoc')/exclude-list/exclude-attr">
    <xsl:when test="$currentAttr=.">
      <xsl:copy-of select="$currentNode"/>


Obvisouly, this is flawed, I get multiple modify-attr elements copied to the
output because I cannot see a way of ensuring the for-each only copies a
permitted node once and once only.

I've a feeling this is approaching the problem from the wrong way....

Current Thread


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.
First Name
Last Name
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.