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

Re: Need an XPath expression which returns all xs:patt

Subject: Re: Need an XPath expression which returns all xs:pattern elements containing a regex that permits an unbounded number of characters
From: "David Carlisle d.p.carlisle@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Thu, 4 Apr 2024 16:11:44 -0000
Re:  Need an XPath expression which returns all xs:patt
On Thu, 4 Apr 2024 at 16:46, Roger L Costello costello@xxxxxxxxx <
xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote:

> David Carlisle devised a brilliant approach:
>
> Do a series of replace operations:
>
> remove all whitespace:
>
>     replace(@value,'\s','')
>
> replace \-quoted characters by x:
>
>     replace(@value,'\\.','x')
>
> replace {99,} constructs by *
>
>     replace(@value,'\{[0-9]+,\}','*')
>
> Here are the replaces, inlined:
>
> replace(replace(replace(@value,'\{[0-9]+,\}','*'),'\\.','x'),'\s','')
>
> Here are the results of applying the replaces to some regexes:
>
> A*  --> apply replaces --> A*
> A+  --> apply replaces --> A+
> A\*  --> apply replaces --> Ax
> A\+  --> apply replaces --> Ax
> A{0,} --> apply replaces --> A*
> A{1,} --> apply replaces --> A*
> A{5,} --> apply replaces --> A*
> \\* --> apply replaces --> x*
>
> To implement "Find all xs:pattern elements that permit an unbounded number
> of characters" do this:
>
>         If the string resulting from applying the replaces
>         contains * or +, then the regex permits an
>         unbounded number of characters.
>
> David (or anyone), is this correct?
>

it's what I said but not correct (or I would rather say, I left you some
further cases as an exercise) you need more normalisation eg '[*] matches
one character as does [{0,}]  so you need to replace something like
\[[^\]*\]` before testing

David


> /Roger

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.