Re: Aw: [xsl] Need an XPath expression which returns all xs:pattern elements containing a regex that permits an unbounded number of characters

Subject: Re: Aw: [xsl] Need an XPath expression which returns all xs:pattern elements containing a regex that permits an unbounded number of characters
From: "Edward Porter edward.porter@xxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Thu, 4 Apr 2024 12:52:21 -0000
Yes, sorry, my answer is also predicated on using matches, e.g.,
matches(@value, '[a-zA-Z]+(\*|\+|\{\d(,.\})?)')

From: Martin Honnen martin.honnen@xxxxxx
<xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Sent: Thursday, April 4, 2024 8:43 AM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: Aw: [xsl] Need an XPath expression which returns all xs:pattern
elements containing a regex that permits an unbounded number of characters


EXTERNAL
Well, instead of contains use matches with a regular expression, I suppose.

--
Diese Nachricht wurde von meinem Android Mobiltelefon mit GMX Mail gesendet.
Am 04.04.24, 14:29 schrieb "Roger L Costello
costello@xxxxxxxxx<mailto:costello@xxxxxxxxx>"
<xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx<mailto:xsl-list-service@xxxxxxxxxxxx
rytech.com>>:
Hi Folks,

I want to find, in an XML Schema, all xs:pattern elements containing a regex
that permits an unbounded number of characters.

Here are examples of xs:pattern elements that I want to find:

<xs:pattern value="A*"/>
<xs:pattern value="A+"/>
<xs:pattern value="A{0,.}"/>
<xs:pattern value="A{1,.}"/>

I do not want either of the following xs:pattern elements because -- due to
the escape symbol -- they do not permit an unbounded number of characters:

<xs:pattern value="A\*"/>
<xs:pattern value="A\+"/>

I created an XPath 2.0 expression to find the desired xs:pattern elements:

xs:pattern[
contains(@value, '*') or
contains(@value, '+') or
contains(@value, '{1,}') or
contains(@value, '{0,}')
]

Eek! That is not correct. It incorrectly returns the xs:pattern elements with
escaped asterisk and escaped plus symbols:

<xs:pattern value="A\*"/>
<xs:pattern value="A\+"/>

How to fix my XPath expression? Is the solution to add a second predicate:

xs:pattern[
contains(@value, '*') or
contains(@value, '+') or
contains(@value, '{1,}') or
contains(@value, '{0,}')
][
not(contains(@value, '\*')) and
not(contains(@value, '\+'))
]

Is that correct? Is that the best approach? Is there a better approach?

Bonus points if you can answer this question: Is my XPath expression catching
all xs:pattern elements that have a regex that permits an unbounded number of
characters?

Note: For reasons that I will not explain, the XPath expression must be an
XPath 2.0 expression.

/Roger




XSL-List info and
archive<https://protect.checkpoint.com/v2/___http://www.mulberrytech.com/xsl/
xsl-list___.YzJ1OnNhc2luc3RpdHV0ZTpjOm86YTI1YzE4NDQyYWYyNjNhMmRlYjczMDM5NmI4Z
DU2YmY6NjplODMwOjUwZmY1ZjBiYmM5NDIzZWMzOTliMWU0MDY1OTdkYjIwMTU1YjJjYmZlZjBmZD
Y2ODdmMDAzMjZlM2IxZWQyZjU6aDpU>
EasyUnsubscribe<https://protect.checkpoint.com/v2/___http://lists.mulberrytec
h.com/unsub/xsl-list/3195664___.YzJ1OnNhc2luc3RpdHV0ZTpjOm86YTI1YzE4NDQyYWYyN
jNhMmRlYjczMDM5NmI4ZDU2YmY6Njo5YTc4OjQwNjU3ODVhM2MyZTQ0NzI2MTAwNmU4OTgxNmU3Yz
gyNTEwNDM4ZmI2N2VhMmY2ZTgyMTllYmNkZTUxMTBjNmE6aDpU> (by email<>)

Current Thread