[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
> I apologize for this, but it looks like I slightly misstated the
> problem. I tested your solution and it looks like exactly what I'm
> looking for, with one difference: it is not <a> that contains the
> superset of attributes, with <b> containing a subset. It's actually
> <b> that contains the superset, and <a> contains the subset.
>
> This variation seems to work for me:
>
> <xsl:variable name="file2" select="document('2.xml')/outsidedata"/>
> <xsl:template match="a">
> <xsl:variable name="a" select="." />
> <xsl:for-each select="$file2/b[@* = $a/@*]">
> <xsl:variable name="b" select="." />
> <xsl:variable name="test">
> <xsl:for-each select="$a/@*">
> <xsl:if test="not($b/@*[name() = name(current())] = .)">
> no attribute with the same name on element b whose value equals this one
> </xsl:if>
> </xsl:for-each>
> </xsl:variable>
> <xsl:if test="not(string($test))">
> [<xsl:value-of select="."/>]
> </xsl:if>
> </xsl:for-each>
> </xsl:template>
Hi Zack,
I don't understand why Jeni's solution should be wrong. With your sentence
<p>The quick brown <a x="1" y="2" z="3">fox</a> jumps over the lazy <a x="9" y="8" z="7">dog</a>.</p>
and the second file
I get the output
"The quick brown [PPP][QQQ][RRR] jumps over the lazy [SSS]."
This is exactly what I expect after reading your first posting again. With your stylesheet I get
"The quick brown jumps over the lazy ."
This seems not to be ok. I thought that the <b>s must not have all attributes from <a>, but may not have other than <a> and not the same with a different value.
And my comments/questions to Jeni's stylesheet:
I thought of a filter too, but I didn't find a sensible one. The above one isn't completely logical to me. What exactly does it mean? Maybe "all <b>s, whose all attributes are in <a> and don't have a different value"?
This is a little bit easier ;-)
This is easier again. Of course a test on "contains($test, 'false')" is not necessary.
Joerg
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Re: [xsl] Identifying two tags that share some attribute names and values
Subject: Re: [xsl] Identifying two tags that share some attribute names and values From: Joerg Heinicke <joerg.heinicke@xxxxxx> Date: Sun, 05 May 2002 20:17:05 +0200 |
> I apologize for this, but it looks like I slightly misstated the
> problem. I tested your solution and it looks like exactly what I'm
> looking for, with one difference: it is not <a> that contains the
> superset of attributes, with <b> containing a subset. It's actually
> <b> that contains the superset, and <a> contains the subset.
>
> This variation seems to work for me:
>
> <xsl:variable name="file2" select="document('2.xml')/outsidedata"/>
> <xsl:template match="a">
> <xsl:variable name="a" select="." />
> <xsl:for-each select="$file2/b[@* = $a/@*]">
> <xsl:variable name="b" select="." />
> <xsl:variable name="test">
> <xsl:for-each select="$a/@*">
> <xsl:if test="not($b/@*[name() = name(current())] = .)">
> no attribute with the same name on element b whose value equals this one
> </xsl:if>
> </xsl:for-each>
> </xsl:variable>
> <xsl:if test="not(string($test))">
> [<xsl:value-of select="."/>]
> </xsl:if>
> </xsl:for-each>
> </xsl:template>
Hi Zack,
I don't understand why Jeni's solution should be wrong. With your sentence
<p>The quick brown <a x="1" y="2" z="3">fox</a> jumps over the lazy <a x="9" y="8" z="7">dog</a>.</p>
and the second file
<outsidedata> <b x="1" y="2">PPP</b> <b y="2" z="3">QQQ</b> <b z="3">RRR</b> <b x="9" z="7">SSS</b> <b m="2" z="3">TTT</b> </outsidedata>
I get the output
"The quick brown [PPP][QQQ][RRR] jumps over the lazy [SSS]."
This is exactly what I expect after reading your first posting again. With your stylesheet I get
"The quick brown jumps over the lazy ."
This seems not to be ok. I thought that the <b>s must not have all attributes from <a>, but may not have other than <a> and not the same with a different value.
And my comments/questions to Jeni's stylesheet:
>><xsl:template match="a"> >> <xsl:variable name="a" select="." />
<xsl:for-each select="$file2/b[@* = $a/@*]">
I thought of a filter too, but I didn't find a sensible one. The above one isn't completely logical to me. What exactly does it mean? Maybe "all <b>s, whose all attributes are in <a> and don't have a different value"?
<xsl:variable name="test"> <xsl:for-each select="@*"> <xsl:if test="not($a/@*[name() = name(current())] = .)">
This is a little bit easier ;-)
no attribute with the same name on element a whose value equals this one </xsl:if> </xsl:for-each> </xsl:variable> <xsl:if test="not(string($test))">
This is easier again. Of course a test on "contains($test, 'false')" is not necessary.
<xsl:text />[<xsl:value-of select="." />]<xsl:text /> </xsl:if> </xsl:for-each> </xsl:template>
Joerg
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Identifying two tags that, Zack Brown | Thread | Re: [xsl] Identifying two tags that, Zack Brown |
RE: [xsl] Finding the lowest 'price, Michael Kay | Date | [xsl] ANN: Article on XSLT in MSXML, Stuart Celarier |
Month |