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

XSLT program that generates XSD, the XSD has a pattern

Subject: XSLT program that generates XSD, the XSD has a pattern facet, the regex has curly braces, the curly braces are causing me trouble
From: "Costello, Roger L. costello@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Wed, 19 Jul 2017 12:44:15 -0000
 XSLT program that generates XSD
Hi Folks,

I am writing an XSLT program that outputs an XML Schema.

The generated XML Schema is to contain a simpleType, with a pattern facet. Its
regex is to express: zero or more lowercase letters of the English alphabet,
the left curly brace, and the right curly brace:

<xs:simpleType name="Stuff">
    <xs:restriction base="xs:string">
        <xs:pattern value="[a-z\{\}]*" />
    </xs:restriction>
</xs:simpleType>

The curly braces are special symbols in the regex language, so I escaped them:
\{ and \}

Interestingly, the curly braces are also special symbols in the XSLT language.
That's causing me problems.

Below is my XSLT program. It doesn't work  - an error is generated because of
the curly braces. Note that replacing the curly braces with their character
references also failed:

<xs:pattern value="[a-z\&#x7B;\ &#x7D;]*" />

What's the right way to do this?  /Roger

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    	xmlns:xs="http://www.w3.org/2001/XMLSchema"
    	exclude-result-prefixes="xs"
    	version="2.0">

    <xsl:output method="xml" />

    <xsl:template match="/">
        <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
            <xs:element name="Test" type="Stuff" />
            <xs:simpleType name="Stuff">
                <xs:restriction base="xs:string">
                    <xs:pattern value="[a-z\{\}]*" />
                </xs:restriction>
            </xs:simpleType>
        </xs:schema>
    </xsl:template>

</xsl:stylesheet>

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.