[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: new: how to change value of attributes

Subject: RE: new: how to change value of attributes
From: "ivanmacculi\@libero\.it" <ivanmacculi@xxxxxxxxx>
Date: Wed, 25 Nov 2009 20:18:40 +0100
RE:  new: how to change value of attributes
thanks Michael Kay, i have appreciated your very important valued. i use XSL
for my work, i 've studied XML with books of Scott Means e Rusty Harold and
XSL with that one of van Otegem, but i don't understand what you wrote. Where
can i find something about Xpath expression? in the site of W3C, for example,
i cant' find what does ^ mean and f:index-of-node too. Can you explane me?
Thank you a lot.


> >    <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>
> >
>
> The redundancy of repeating the whole pattern is pretty horrible, both for
> performance and for maintenance.
>
> An idiom I have used in such cases is:
>
> <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, .)"/>
>
> where
>
> <xsl:function name="f:index-of-node" as="xs:integer*">
>   <xsl:param name="nodes" as="node()*"/>
>   <xsl:param name="node" as="node()"/>
>   <xsl:for-each select="$nodes">
>     <xsl:sequence select="position()[current() is $node]"/>
>   </xsl:for-each>
> </xsl:function>
>
> which still isn't ideal, but it feels a bit better.
>
>
> Regards,
>
> Michael Kay
> http://www.saxonica.com/
> http://twitter.com/michaelhkay

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.