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

Discussion in 'XML' started by FC, Oct 24, 2003.

  1. FC

    FC Guest

    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
     
    FC, Oct 24, 2003
    #1
    1. Advertising

  2. FC

    Keith Davies Guest

    On Fri, 24 Oct 2003 10:21:04 GMT, FC <> wrote:
    > 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
    --
    Keith Davies "Your ability to bang your head against
    reality in the hope that reality will
    crack first is impressive, but futile"
    -- Geoffrey Brent, rec.games.frp.dnd
     
    Keith Davies, Oct 26, 2003
    #2
    1. Advertising

  3. FC

    FC Guest

    "Keith Davies" <> wrote in message
    news:...
    > On Fri, 24 Oct 2003 10:21:04 GMT, FC <> wrote:
    > > 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
     
    FC, Oct 26, 2003
    #3
  4. FC

    FC Guest

    "FC" <> wrote in message
    news:pVQmb.49152$...
    >
    > "Keith Davies" <> wrote in message
    > news:...
    > > On Fri, 24 Oct 2003 10:21:04 GMT, FC <> wrote:
    > > > 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
     
    FC, Oct 26, 2003
    #4
  5. FC

    Keith Davies Guest

    On Sun, 26 Oct 2003 14:31:49 GMT, FC <> wrote:
    >
    > "Keith Davies" <> wrote in message
    > news:...
    >> On Fri, 24 Oct 2003 10:21:04 GMT, FC <> wrote:
    >> > 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
    --
    Keith Davies "Your ability to bang your head against
    reality in the hope that reality will
    crack first is impressive, but futile"
    -- Geoffrey Brent, rec.games.frp.dnd
     
    Keith Davies, Oct 27, 2003
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Tee
    Replies:
    3
    Views:
    7,817
    Herfried K. Wagner [MVP]
    Jun 23, 2004
  2. Replies:
    0
    Views:
    912
  3. Replies:
    1
    Views:
    452
  4. Replies:
    1
    Views:
    2,482
    Mark P
    Apr 6, 2007
  5. Xah Lee
    Replies:
    4
    Views:
    983
Loading...

Share This Page