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

efficiently extracting a capture group from analyze-s

Subject: efficiently extracting a capture group from analyze-string()
From: "Chris Papademetrious christopher.papademetrious@xxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Sat, 4 Jun 2022 15:29:54 -0000
 efficiently extracting a capture group from  analyze-s
Hi everyone!

Given some filename string like

  <xsl:variable name="file" select="'path/my-sometype.xml'"/>

I'd like to extract the "my-(\w+)" part of the filename using
analyze-string(). So far I have

  <xsl:variable name="my-file-type" select="data(analyze-string($file,
'my-(\w+)')//fn:group[1])"/>

which works by extracting the <group> descendant from the
<analyze-string-result> tree, then converting it to text. Is there a more
concise way to do this?

I had to define

  xmlns:fn=http://www.w3.org/2005/xpath-functions

in my stylesheet for fn:group to match, and I'm not sure if there's a better
way to do that too.

Thanks!


  *   Chris

-----
Chris Papademetrious
Tech Writer, Implementation Group
(610) 628-9718 home office
(570) 460-6078 cell

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.