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


Help: OASIS Mailing Lists Help | MarkMail Help

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]
Re: [xml-dev] Same element, different type

Hi Keith,

If you validate that in oXygen it will also quote you in the error 
report the following link from the spec:

One thing that may get you closer to what you want is to use xsi:type on 
the first parameter to specify a restricted type, but that needs to be 
placed in the instance, like below

<params xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";>
     <param xsi:type="p1">a</param>

with a schema like

<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema";>
     <xs:element name="params">
                 <xs:element minOccurs="2" maxOccurs="2" name="param" 
     <xs:simpleType name="p1">
         <xs:restriction base="xs:string">
             <xs:enumeration value="a"/>
             <xs:enumeration value="b"/>
             <xs:enumeration value="c"/>

One possibility is to embed Schematron in your schema, below you can 
find a working sample:

<xs:element name="params">
             <sch:pattern name="Test the first parameter"
                 <sch:rule context="params">
                     <sch:assert test="param[1]='a' or param[1]='b' or 
                         The first param must be a, b or c
             <xs:element minOccurs="2" maxOccurs="2" name="param" 

Best Regards,
George Cristian Bina
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger

Keith Hassen wrote:
> Hi,
> I have what I suspect is a simple question about element consistency in 
> a schema.  I have recently run across a few scenarios that require me to 
> define something like the following:
>   <xs:element name="params">
>     <xs:complexType>
>       <xs:sequence>
>         <xs:element minOccurs="1" maxOccurs="1" name="param">
>           <xs:simpleType>
>             <xs:restriction base="xs:string">
>               <xs:enumeration value="a"/>
>               <xs:enumeration value="b"/>
>               <xs:enumeration value="c"/>
>             </xs:restriction>
>           </xs:simpleType>
>         </xs:element>
>         <xs:element minOccurs="1" maxOccurs="1" name="param" 
> type="xs:string"/>
>       </xs:sequence>
>     </xs:complexType>
>   </xs:element>
> The definition above isn't ambiguous (which would break the unique 
> particle attribution rule), but it is not *consistent* vis-a-vis the 
> types.  The Xerces parser reports a "cos-element-consistent" error, 
> which I understand, but which I am hoping to circumvent while 
> maintaining strict parsing rules.
> Is there a way to define two unambiguous elements with the same name but 
> are of different types?  I believe the answer here is "it can't be 
> done", but thought I'd throw this at the wolves to see if I'm right. :)
> (Incidentally, the above example is a snippet from a schema that is 
> attempting a representation of an XML-RPC message set, where the first 
> parameter is always a constrained list of possible values, while the 
> second parameter is any string).
> -K
> _______________________________________________________________________
> XML-DEV is a publicly archived, unmoderated list hosted by OASIS
> to support XML implementation and development. To minimize
> spam in the archives, you must subscribe before posting.
> [Un]Subscribe/change address: http://www.oasis-open.org/mlmanage/
> Or unsubscribe: xml-dev-unsubscribe@lists.xml.org
> subscribe: xml-dev-subscribe@lists.xml.org
> List archive: http://lists.xml.org/archives/xml-dev/
> List Guidelines: http://www.oasis-open.org/maillists/guidelines.php

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]

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

Copyright 1993-2007 XML.org. This site is hosted by OASIS