|
[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
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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








