|
Subject: Re: [xsl] XSLT program that generates XSD, the XSD has a pattern facet, the regex has curly braces, the curly braces are causing me trouble From: "David Carlisle d.p.carlisle@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> Date: Wed, 19 Jul 2017 13:07:13 -0000 |
you can avoid putting the string in an attribute value template, as
Syd Bauman just said, or within an AVT use {{ to denote a {
David
On 19 July 2017 at 14:01, Syd Bauman s.bauman@xxxxxxxxxxxxxxxx
<xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote:
> How about using XSLT constructors, so the part of interest is just a
> string?
>
> <xsl:element name="pattern" namespace="http://www.w3.org/2001/XMLSchema">
> <xsl:attribute name="value">
> <xsl:text>[a-z\{\}]*</xsl:text>
> </xsl:attribute>
> </xsl:element>
>
>> 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\{\ }]*" />
>>
>> 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 |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| Re: [xsl] XSLT program that generat, Syd Bauman s.bauman@ | Thread | Re: [xsl] XSLT program that generat, G. Ken Holman g.ken. |
| Re: [xsl] XSLT program that generat, Syd Bauman s.bauman@ | Date | Re: [xsl] XSLT program that generat, G. Ken Holman g.ken. |
| Month |