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

RE: values in sequence after tokenize

Subject: RE: values in sequence after tokenize
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Tue, 11 Jul 2006 16:10:31 +0100
xsl tokenize line
position() gives you the position of a substring within the sequence of
matching and non-matching substrings. To get the position within the
sequence of matching substrings only, I think you will need a second pass.

Michael Kay
http://www.saxonica.com/


> -----Original Message-----
> From: Florent Georges [mailto:darkman_spam@xxxxxxxx]
> Sent: 11 July 2006 15:53
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: Re:  values in sequence after tokenize
>
> andrew welch wrote:
>
>   Hi
>
> > Using xsl:analyze-string, how would I add a count to the matching
> > items:
>
> > <xsl:analyze-string select="$string" regex=".{{1,6}}\^">
> >   <xsl:matching-substring>
> >     <line count="{ ?? }"><xsl:value-of select="."/></line>
> >   </xsl:matching-substring>
> >   <xsl:non-matching-substring>
> >     <non><xsl:value-of select="."/></non>
> >   </xsl:non-matching-substring>
> > </xsl:analyze-string>
>
> > ...so that the output would be:
>
> > <line count="1">....
> > <line count="2">....
>
> > Is this possible or does it require two passes?
>
>   I'm not sure, but if I understood well, you need simply position():
>
>     ~/xslt/tests> cat analyse-string.xsl
>     <xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>                    version="2.0">
>
>       <xsl:output indent="yes" omit-xml-declaration="yes"/>
>
>       <xsl:param name="input" select="'aa^aaa^aaa^^aa'"/>
>
>       <xsl:template name="main">
>         <xsl:analyze-string select="$input" regex=".{{1,6}}\^">
>           <xsl:matching-substring>
>             <line count="{ position() }">
>               <xsl:value-of select="."/>
>             </line>
>           </xsl:matching-substring>
>           <xsl:non-matching-substring>
>             <non>
>               <xsl:value-of select="."/>
>             </non>
>           </xsl:non-matching-substring>
>         </xsl:analyze-string>
>       </xsl:template>
>
>     </xsl:transform>
>
>     ~/xslt/tests> saxon -it main analyse-string.xsl
>     <line count="1">aa^</line>
>     <line count="2">aaa^</line>
>     <line count="3">aaa^</line>
>     <non>^aa</non>
>
>   Regards,
>
> --drkm
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> ______________________________________________________________
> _____________
> Yahoo! Mail riinvente le mail ! Dicouvrez le nouveau Yahoo!
> Mail et son interface rivolutionnaire.
> http://fr.mail.yahoo.com

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.