Re: [xsl] new: how to change value of attributes

Subject: Re: [xsl] new: how to change value of attributes
From: Martin Honnen <Martin.Honnen@xxxxxx>
Date: Fri, 27 Nov 2009 18:16:26 +0100
ivanmacculi@xxxxxxxxx wrote:
I've problems with Michael Kay suggestion:
1) Oxygen tells me to declare f: namespace and xs: namespace:
<xsl:function name="f:index-of-node" as="xs:integer*">.

The xs namespace needs to be http://www.w3.org/2001/XMLSchema so put
xmlns:xs="http://www.w3.org/2001/XMLSchema";
on your xsl:stylesheet element.
To define your own functions you are free to choose a namespace but you need to choose one.


2) <xsl:template match="*[. intersect $g]/@LABEL"> is open but not closed. Where can i close it? thank you so much.

I think Michael's suggestion is to replace


<xsl:template match="mets:div/@LABEL[matches(., '^Pagina [0-9]+$')]">
<xsl:variable name="n">
<xsl:number level="any" count="mets:div[@LABEL[matches(., '^Pagina [0-9]+$')]]"/>
</xsl:variable>
<xsl:attribute name="LABEL" select="concat('Carta ', if ($n mod 2 = 0) then concat(($n + 1) idiv 2, 'v') else concat(($n + 1) idiv 2, 'r'))"/>
</xsl:template>


in the solution I posted with

<xsl:variable name="g" select="//mets:div[matches(@LABEL, '^Pagina
[0-9]+$')]"/>

<xsl:template match="*[. intersect $g]/@LABEL">
<xsl:variable name="n" select="f:index-of-node($g, ..)"/>
<xsl:attribute name="LABEL" select="concat('Carta ', if ($n mod 2 = 0) then concat(($n + 1) idiv 2, 'v') else concat(($n + 1) idiv 2, 'r'))"/>
</xsl:template>


plus the function he posted.



--

	Martin Honnen
	http://msmvps.com/blogs/martin_honnen/

Current Thread