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

Re: merging two documents - only if second document ma

Subject: Re: merging two documents - only if second document matches
From: Jeni Tennison <mail@xxxxxxxxxxxxxxxx>
Date: Sat, 3 Feb 2001 10:54:36 +0000
xsl if document
Oliver Becker wrote:
> <xsl:template match="/">
>    <xsl:for-each select="$idsA[. = $idsB]">
>       <xsl:copy-of select="." />
>    </xsl:for-each>
> </xsl:template>
>
> The question is, if your input is really as simple as you said.
> For example it might be reasonable comparing the normalized string
> values like this
>    normalize-space() = normalize-space($idsB)
> inside of the predicate.

One of those horrible situations where the behaviour of '=' in XPath
turns round and bites you...

In the original path:

  $idsA[. = $idsB]

then you're filtering in any nodes in $idsA whose value is the same
as *any* of the nodes in $idsB.

If you do:

  $idsA[normalize-space() = normalize-space($idsB)]

then the normalize-space($idsB) selects *only the first* of the nodes
in $idsB and gives your its normalized value. So you only get any
$idsA node that has the same value as the first $idsB.

To get round this, you need to work through all the $idsA 'by hand'
and put the test in an xsl:if:

  <xsl:for-each select="$idsA">
     <xsl:if test="$idsB[normalize-space() =
                         normalize-space(current())]">
        <xsl:copy-of select="." />
     </xsl:if>
  </xsl:for-each>

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/



 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


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.