Re: [xsl] Need an XPath expression for: $B is not contained in $A

Subject: Re: [xsl] Need an XPath expression for: $B is not contained in $A
From: "Eliot Kimber ekimber@xxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Thu, 14 Jun 2018 13:38:20 -0000
Doh!--how do I keep failing to understand that "=" is atomic value
comparison?

Maybe I shouldn't try to solve XSLT puzzles first thing in  the morning.

Cheers,

E.

--
Eliot Kimber
http://contrext.com


o;?On 6/14/18, 8:35 AM, "Martin Honnen martin.honnen@xxxxxx"
<xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote:

    On 14.06.2018 15:23, Eliot Kimber ekimber@xxxxxxxxxxxx wrote:
    > This seems to work:
    >
    > <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
    >    xmlns:xs="http://www.w3.org/2001/XMLSchema";
    >    exclude-result-prefixes="xs"
    >    version="2.0">
    >    <xsl:template match="/">
    >      <xsl:variable name="doc" as="document-node()">
    >        <xsl:document>
    >        <root>
    >          <a>
    >            <c>
    >              <b>This is b 1</b>
    >            </c>
    >            <d>This is d</d>
    >          </a>
    >          <f>
    >            <c>
    >              <b>This is b 2</b>
    >            </c>
    >          </f>
    >        </root>
    >        </xsl:document>
    >      </xsl:variable>
    >
    >      <xsl:variable name="A" as="element()" select="$doc/*/a"/>
    >      <xsl:variable name="B1" as="element()" select="$doc/*/a/c/b"/>
    >      <xsl:variable name="B2" as="element()" select="$doc/*/f/c/b"/>
    >      <result>
    >        <test>b1 in A: <xsl:value-of select="$B1/ancestor::* =
$A"/></test>
    >        <test>b2 in A: <xsl:value-of select="$B2/ancestor::* =
$A"/></test>

    Comparing the string value with "=" does not compare the node identity
    so I don't think this is a good idea, unless textual equality is sought.

Current Thread