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

Re: construct dynamic replacement value in replace()?

Subject: Re: construct dynamic replacement value in replace()?
From: "Martin Honnen martin.honnen@xxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Mon, 30 Oct 2017 17:51:13 -0000
Re:  construct dynamic replacement value in replace()?
On 30.10.2017 18:47, Martin Honnen martin.honnen@xxxxxx wrote:
On 30.10.2017 18:33, Birnbaum, David J djbpitt@xxxxxxxx wrote:

The desired output would be '11 Tim. 14:133', that is, each sequence of digits would be regarded as a discrete decimal numerical value, captured as the match with '$0', and passed to the local:stuff() function, where it would be converted to a number. augmented by 10, converted back to a string (since the replacement part of the replace() function must be a string), and returned. The actual output, alas, is 'NaN Tim. NaN:NaN'. Before I give up and do it in XSLT, I would be grateful for any pointers toward an XPath or XQuery solution.

XPath 3.1 can do it with analyze-string:


let $initial := '1 Tim. 4:123'
return string-join(analyze-string($initial, '[0-9]+')/*!(if (local-name() eq 'match') then . + 10 else string()))

Perhaps that element check is better implemented as


let $initial := '1 Tim. 4:123'
return string-join(analyze-string($initial, '[0-9]+')/*!(if (. instance of element(fn:match)) then . + 10 else string()))


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.