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

Re: Re: Getting the offset of a matching-substring in

Subject: Re: Re: Getting the offset of a matching-substring in <xsl:analyze-string>
From: Michael Kay <mike@xxxxxxxxxxxx>
Date: Fri, 16 Mar 2012 21:09:51 +0000
Re:  Re: Getting the offset of a matching-substring in
The new fn:analyze-string() function in XPath 3.0, designed to deliver the benefits of xsl:analyze-string to XQuery users, produces as output a copy of the input string with added markup to identify the matching and non-matching substrings, and the captured groups. So you can examine this output to see where the captured groups are in the string; but it's still a second pass of a kind.

http://www.w3.org/TR/xpath-functions-30/#func-analyze-string

Michael Kay
Saxonica

On 16/03/2012 20:57, Martin Holmes wrote:
That's what I did in the end. It would be nice not to have to, though.

Cheers,
Martin

On 12-03-15 05:49 PM, Imsieke, Gerrit, le-tex wrote:
I think you need a second pass to calculate the offsets.

On 2012-03-16 01:00, Martin Holmes wrote:
Hi there,

I'm doing some automated markup using <xsl:analyze-string>, and as part
of the output I'd like to record the offset and length of each matched
substring. So given input like this in a text node (simplified example):


This is a test.

and a match like this:

<xsl:analyze-string select="$input" regex="{'[a-zA-Z]+'}">

<xsl:matching-substring>

<w offset="???" length="{string-length(.)}">

<xsl:value-of select="."/>

</w>

<xsl>matching-substring>

</xsl:analyze-string>

I'm wondering if there's any way I can calculate the offset value (which
for "This" would be 1, for "is" would be 6, etc.).


Does anyone know if there's a way to do this?

All help appreciated,
Martin

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.