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

XPath expression to convert XSD enumerations into a r

Subject: XPath expression to convert XSD enumerations into a regex, longest value first
From: "Roger L Costello costello@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Thu, 7 Jul 2022 17:02:06 -0000
 XPath expression to convert XSD enumerations into a  r
Hi Folks,

I have an XSD simpleType with enumeration values:

<xsd:simpleType name="RunwayLightingType">
  <xsd:restriction base="xsd:string">
   <xsd:enumeration value="1"/>
   <xsd:enumeration value="2"/>
   <xsd:enumeration value="3"/>
   <xsd:enumeration value="4"/>
   <xsd:enumeration value="5"/>
   <xsd:enumeration value="6"/>
   <xsd:enumeration value="7"/>
   <xsd:enumeration value="8"/>
   <xsd:enumeration value="9"/>
   <xsd:enumeration value="10"/>
   <xsd:enumeration value="11"/>
   <xsd:enumeration value="12"/>
  </xsd:restriction>
 </xsd:simpleType>

I want to turn the values into a regex such that the longest value (not the
biggest value, the string longest value) is listed first:

12|11|10|9|8|7|6|5|4|3|2|1

Seems like a simple problem, right? Should have a simple solution, right?

Well, I devised a solution, but it sure ain't simple.

string-join(for $i in reverse(sort(xs:restriction/xs:enumeration, (),
function($enum) {string-length($enum/@value )})) return $i/@value, '|')

Is there is a simpler XPath expression to solve this problem?

/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.