AW: [xsl] Deleting a node depending on contents of a grandfather attribute and a child node

Subject: AW: [xsl] Deleting a node depending on contents of a grandfather attribute and a child node
From: Markus Abt <abt@xxxxxxxx>
Date: Thu, 31 Jul 2003 01:46:55 +0200
Hi,

true, you cannot use a variable in the match pattern.
So you have to do either:

<xsl:template match="absent">
  <xsl:if test="not(from = $vardate and ancestor::player/@pword = $varpword)">
    <xsl:copy>
      <xsl:apply-templates select="@*|node()"/>
    </xsl:copy>
  </xsl:if>
</xsl:template>

or

<xsl:template match="absentia">
  <xsl:copy>
    <xsl:apply-templates select="@*|node()[not(from = $vardate and ancestor::player@pword = $varpword)]"/>
  </xsl:copy>
</xsl:template>


Regards,
Markus

__________________________
Markus Abt
Comet Computer GmbH
http://www.comet.de


----------
Von: 	John Reid
Gesendet: 	Mittwoch, 30. Juli 2003 23:50
An: 	xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Betreff: 	RE: [xsl] Deleting a node depending on contents of a grandfather attribute and a child node

I understood that I could not use variables in a template match
statement such as
<xsl:template match="absent[ancestor::player/@pword=$varpword
    and from=$vardate]"/>
Or am I missing something?
Salud
John
John Reid wrote:
> i have tried a number of approaches but with various but not correct
> results. I want to delete the absent node (and everything below it)
> where $vardate = from and @pword $varpword.
..
>     <xsl:variable name="pword" select="ancestor::@pword"/>
Wont select anything, ever. Try
      <xsl:variable name="pword" select="ancestor::player[1]/@pword"/>
or if the player node is always the grandfather
      <xsl:variable name="pword" select="../../@pword"/>

>     <xsl:copy>
>       <xsl:apply-templates select="@*|node()[not($date1 = $vardate and
> $pword = $varpword)]"/>
>   </xsl:copy>

This does not quite match your problem description ("I want to
delete the absent node"). The following template
  <xsl:template match="absent[ancestor::player/@pword=$varpword
    and from=$vardate]"/>
will make processing the nodes in questions a no-op (iow kill it),
other absent nodes are copied through by the other template.

J.Pietschmann



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


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



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


Current Thread