[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

RE: [xsl] Using copy to change a node, whilst retaining the attributes


Subject: RE: [xsl] Using copy to change a node, whilst retaining the attributes
From: "John Reid" <John.Reid@xxxxxxxxxxxxxxx>
Date: Tue, 5 Aug 2003 09:57:10 +1000

Thanx,
I am rushing at this time ( and it shows ;o))as I am aware that night
time is falling over there(UK and USA) and the xsl-list goes quiet. I'll
try that, I also tried the below and it works ok although it seems heavy
on processing as the test is applied at the bottom of the tree.

Salud

John Reid

When @pword="843208" and @ID>=20030808 and @ID<=20030810 make the yes
text = "C"
Salud

John 

<player pword="843208">
  <dates>
	<yes ID="20030722" WE="Tu">A</yes>
>     <yes ID="20030729" WE="Tu">A</yes>
>     <yes ID="20030805" WE="Tu">A</yes>
>     <yes ID="20030809" WE="Sa">D</yes>

<player pword="843208">
  <dates>
     <yes ID="20030722" WE="Tu">A</yes>
>     <yes ID="20030729" WE="Tu">A</yes>
>     <yes ID="20030805" WE="Tu">A</yes>
>     <yes ID="20030809" WE="Sa">C</yes>

<xsl:param name="pmkey" select="0" />
<xsl:param name="type" select="0" />
<xsl:param name="from" select="0" />
<xsl:param name="to" select="0" />

<xsl:template match="@*|node()">
<xsl:copy>
    <xsl:apply-templates select="@*|node()"/>
  </xsl:copy>
</xsl:template>

<xsl:template match="yes/text()">
<xsl:copy>
<xsl:copy-of select="node()[not(ancestor::player/@pword=$pmkey and @ID
&gt;= $from and @ID &lt;= $to)]" />
  <xsl:value-of select="$type" />
</xsl:copy>
</xsl:template>


apply-templates requires a node set as the value of its select
attribute, but:

	<xsl:apply-template select="not(ancestor::player/@pword=$pmkey
and @ID &gt;= $from and @ID &lt;= $to)"

assuming the missing /> is really there at the end selects a boolean
value so either true() or false(0 this isn't a node set and should
generate a run time error whatever value is returned.

I think that inside the xsl:copy you want

<xsl:choose>
 <xsl:when test="ancestor::player/@pword=$pmkey
                and @ID &gt;= $from and @ID &lt;= $to">
  <xsl:value-of select="$type"/>
</xsl:when>
<xsl:otherwise><xsl:value-of select="."/></xsl:otherwise>
</xsl:choose>

don't you?

David

 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