how to create a case-insensitive pattern facet in XML Schema?

F

FC

Hello folks,

I'd like to make the following simple type definition case insensitive:


<xsd:simpleType name="MyType">

<xsd:restriction base="xsd:string">

<xsd:pattern value="(TRUE|FALSE|('([a-zA-Z0-9])+'))
?(NOOVERRIDE)?"/>

</xsd:restriction>

</xsd:simpleType>

As you can easily guess, if I later use an attribute of type MyType in an
instance document:

MyAttribute="TRUE NOOVERRIDE"

will be ok, but

MyAttribute="true NoOverride"

won't validate.

Even if I supply more combinations of the keywords like "True", "true" and
so on, this doesn't solve the problem in an elegant fashion.

Is there a better solution?

Bye,

Flavio
 
K

Keith Davies

Hello folks,

I'd like to make the following simple type definition case insensitive:


<xsd:simpleType name="MyType">

<xsd:restriction base="xsd:string">

<xsd:pattern value="(TRUE|FALSE|('([a-zA-Z0-9])+'))
?(NOOVERRIDE)?"/>

</xsd:restriction>

</xsd:simpleType>

As you can easily guess, if I later use an attribute of type MyType in an
instance document:

MyAttribute="TRUE NOOVERRIDE"

will be ok, but

MyAttribute="true NoOverride"

won't validate.

Your pattern, if I understand it correctly, allows one of
"TRUE"
"TRUE NOOVERRIDE"
"FALSE"
"FALSE NOOVERRIDE"
"[a-zA-Z0-9]+"
"[a-zA-Z0-9]+ NOOVERRIDE"

*IF* I understand it correctly (I'm not an expert in XSD, but I often
use patterns in other places) "true NOOVERRIDE" will fit last rule, not
the second.


Keith
 
F

FC

Keith Davies said:
Hello folks,

I'd like to make the following simple type definition case insensitive:


<xsd:simpleType name="MyType">

<xsd:restriction base="xsd:string">

<xsd:pattern value="(TRUE|FALSE|('([a-zA-Z0-9])+'))
?(NOOVERRIDE)?"/>

</xsd:restriction>

</xsd:simpleType>

As you can easily guess, if I later use an attribute of type MyType in an
instance document:

MyAttribute="TRUE NOOVERRIDE"

will be ok, but

MyAttribute="true NoOverride"

won't validate.

Your pattern, if I understand it correctly, allows one of
"TRUE"
"TRUE NOOVERRIDE"
"FALSE"
"FALSE NOOVERRIDE"
"[a-zA-Z0-9]+"
"[a-zA-Z0-9]+ NOOVERRIDE"

*IF* I understand it correctly (I'm not an expert in XSD, but I often
use patterns in other places) "true NOOVERRIDE" will fit last rule, not
the second.


Keith


Well, unfortunately you didn't understand it correctly :)
The expression in square parentesys is enclosed by tick marks and they must
be present, moreover the meaning of a string inside tick marks is completely
different from a "token" like TRUE from the application standpoint, which
ultimately means that TRUE is not equal to 'true'.
So, back to my original posting, I found later a w3c document explaining why
case-insensitive facets are a bad idea so I restrained myself to using only
uppercase tokens.

Bye,
Flavio
 
F

FC

FC said:
Keith Davies said:
Hello folks,

I'd like to make the following simple type definition case insensitive:


<xsd:simpleType name="MyType">

<xsd:restriction base="xsd:string">

<xsd:pattern value="(TRUE|FALSE|('([a-zA-Z0-9])+'))
?(NOOVERRIDE)?"/>

</xsd:restriction>

</xsd:simpleType>

As you can easily guess, if I later use an attribute of type MyType in an
instance document:

MyAttribute="TRUE NOOVERRIDE"

will be ok, but

MyAttribute="true NoOverride"

won't validate.

Your pattern, if I understand it correctly, allows one of
"TRUE"
"TRUE NOOVERRIDE"
"FALSE"
"FALSE NOOVERRIDE"
"[a-zA-Z0-9]+"
"[a-zA-Z0-9]+ NOOVERRIDE"

*IF* I understand it correctly (I'm not an expert in XSD, but I often
use patterns in other places) "true NOOVERRIDE" will fit last rule, not
the second.


Keith


Well, unfortunately you didn't understand it correctly :)
The expression in square parentesys is enclosed by tick marks and they must
be present, moreover the meaning of a string inside tick marks is completely
different from a "token" like TRUE from the application standpoint, which
ultimately means that TRUE is not equal to 'true'.
So, back to my original posting, I found later a w3c document explaining why
case-insensitive facets are a bad idea so I restrained myself to using only
uppercase tokens.

Bye,
Flavio

As an additional remark, if one wants to create a truly case insensitive
tokens, then the only way is to "spell" each word like this:
([tT][rR][uU][eE])|([fF][aA][lL][sS][eE])... and so on.

Bye,
Flavio
 
K

Keith Davies

Keith Davies said:
Hello folks,

I'd like to make the following simple type definition case insensitive:


<xsd:simpleType name="MyType">

<xsd:restriction base="xsd:string">

<xsd:pattern value="(TRUE|FALSE|('([a-zA-Z0-9])+'))
?(NOOVERRIDE)?"/>

</xsd:restriction>

</xsd:simpleType>

As you can easily guess, if I later use an attribute of type MyType in an
instance document:

MyAttribute="TRUE NOOVERRIDE"

will be ok, but

MyAttribute="true NoOverride"

won't validate.

Your pattern, if I understand it correctly, allows one of
"TRUE"
"TRUE NOOVERRIDE"
"FALSE"
"FALSE NOOVERRIDE"
"[a-zA-Z0-9]+"
"[a-zA-Z0-9]+ NOOVERRIDE"

*IF* I understand it correctly (I'm not an expert in XSD, but I often
use patterns in other places) "true NOOVERRIDE" will fit last rule, not
the second.


Keith


Well, unfortunately you didn't understand it correctly :)
The expression in square parentesys is enclosed by tick marks and they must
be present,

However, they are part of a selection. If I read your pattern
correctly, the relevant part is:

TRUE | FALSE | ('([a-zA-Z0-9])+')

Now, I'm more familiar with Perl RE than XSD patterns, but so far as I
understand, this says "TRUE, or FALSE, or some series of alphanumerics
with at least one character". I infer that the '?(NOOVERRIDE)?'
portion indicates that the string "NOOVERRIDE" is optional.
moreover the meaning of a string inside tick marks is completely
different from a "token" like TRUE from the application standpoint, which
ultimately means that TRUE is not equal to 'true'.

Which is what I said, is it not? Well, more or less; I said that it
would match the series of alphanumerics, not the TRUE portion.
So, back to my original posting, I found later a w3c document explaining why
case-insensitive facets are a bad idea so I restrained myself to using only
uppercase tokens.

That's what I'd do. Case insensitivity, IME, generally causes pain.


Keith
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,226
Members
46,815
Latest member
treekmostly22

Latest Threads

Top