xsl-list
[Top] [All Lists]

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

2009-11-27 12:16:54
ivanmacculi(_at_)libero(_dot_)it 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[(_at_)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/

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>