OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

 


 

   Re: [xml-dev] Simple xs:restriction issue

[ Lists Home | Date Index | Thread Index ]

Hi Jimmy,

The schema is valid, but the pattern is not doing what you want it to do.
The facet constraints are effectively ANDed together so a value has to match
both the pattern constraint and the enumeration constraint.  (Enumerations
are one of the nastier XSD versioning traps in my opinion!)

One approach I've suggested to others in the past is to use unions, e.g.
something like (I haven't compiled it so it might have some syntax errors):

  <xs:simpleType name="TypeTypeAvion">
    <xs:union memberTypes="TypeTypeAvionDefined   TypeTypeAvionExtension"/>
  </xs:simpleType>

<xs:simpleType name="TypeTypeAvionDefined">
    <xs:restriction base="xs:string">
      <xs:enumeration value="SEM 3"/>
      <xs:enumeration value="SEM 4"/>
      <xs:enumeration value="Rafale F1"/>
      <xs:enumeration value="M2000D R2"/>
      <xs:enumeration value="M2000N K2"/>
      <xs:enumeration value="M2000DA S4-2A"/>
      <xs:enumeration value="M2000DA S5-2C"/>
      <xs:enumeration value="M2000-5F SF1-C"/>
      <xs:enumeration value="F1 CT T2"/>
      <xs:enumeration value="F1 CR F7"/>
    </xs:restriction>
  </xs:simpleType>

<xs:simpleType name="TypeTypeAvionExtension">
    <xs:restriction base="xs:string">
      <xs:pattern value=".*"/>
    </xs:restriction>
  </xs:simpleType>

I would be interested to hear from the experts as to whether this is a
sensible approach.

HTH,

Pete.
--
=============================================
Pete Cordell
for XML to C++ data binding visit
http://www.tech-know-ware.com/lmx
(or http://www.xml2cpp.com)
=============================================

----- Original Message ----- 
From: "Jimmy Monin" <jm.ais40@wanadoo.fr>
To: <xml-dev@lists.xml.org>
Sent: Wednesday, November 16, 2005 4:57 PM
Subject: [xml-dev] Simple xs:restriction issue


> Hi all,
>
> I have to deal with the following schema defined as an interface with a
> proprietary software :
> .
> .
> .
>  <xs:simpleType name="TypeTypeAvion">
>    <xs:restriction base="xs:string">
>      <xs:enumeration value="SEM 3"/>
>      <xs:enumeration value="SEM 4"/>
>      <xs:enumeration value="Rafale F1"/>
>      <xs:enumeration value="M2000D R2"/>
>      <xs:enumeration value="M2000N K2"/>
>      <xs:enumeration value="M2000DA S4-2A"/>
>      <xs:enumeration value="M2000DA S5-2C"/>
>      <xs:enumeration value="M2000-5F SF1-C"/>
>      <xs:enumeration value="F1 CT T2"/>
>      <xs:enumeration value="F1 CR F7"/>
>      <xs:pattern value=".*"/>
>    </xs:restriction>
>  </xs:simpleType>
> .
> .
> .
> The main idea was (I guess) to start defining a list of acceptable value,
> but still accept any (use of pattern). With Xerces2 included in JAXP 1.21,
> I get an error message (value not valid with respect to its type) with a
> string that differs from those listed.
> My question is : is this schema definition valid?
>
> Thanks in advance,
>
> -- 
> Jimmy Monin
>
> SCM & Development
> EADS Systems & Defence Electronics
>
>
>
> -----------------------------------------------------------------
> The xml-dev list is sponsored by XML.org <http://www.xml.org>, an
> initiative of OASIS <http://www.oasis-open.org>
>
> The list archives are at http://lists.xml.org/archives/xml-dev/
>
> To subscribe or unsubscribe from this list use the subscription
> manager: <http://www.oasis-open.org/mlmanage/index.php>
>
>






 

News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 2001 XML.org. This site is hosted by OASIS