Re: Using xsd:type in xml files

Hi Nicolas,

Here it is an example, it may help. From the error message it seems that 
you are using the wrong namespace for the type attribute.

test.xsd
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
     <xs:element name="foo" type="foo"/>
     <xs:complexType name="foo">
         <xs:sequence>
             <xs:element ref="bar" maxOccurs="unbounded"/>
         </xs:sequence>
     </xs:complexType>
     <xs:element name="bar" type="bar"/>
     <xs:complexType name="bar"/>
     <xs:complexType name="bar1">
         <xs:complexContent>
             <xs:extension base="bar">
                 <xs:choice>
                     <xs:element name="bar1Content"/>
                 </xs:choice>
             </xs:extension>
         </xs:complexContent>
     </xs:complexType>
     <xs:complexType name="bar2">
         <xs:complexContent>
             <xs:extension base="bar">
                 <xs:choice>
                     <xs:element name="bar2Content"/>
                 </xs:choice>
             </xs:extension>
         </xs:complexContent>
     </xs:complexType>
</xs:schema>

valid instance:

<foo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:noNamespaceSchemaLocation="test.xsd">
     <bar xsi:type="bar1">
         <bar1Content></bar1Content>
     </bar>
     <bar xsi:type="bar2">
         <bar2Content></bar2Content>
     </bar>
     <bar/>
</foo>

Regards,
George
---------------------------------------------------------------------
George Cristian Bina
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com


Nicolas Mailhot wrote:
> 
> On Lun 11 avril 2005 11:07, George Cristian Bina a écrit :
> 
>>Hi Nicolas,
>>
>>I read your post between lines, but it seems that you are looking for
>>xsi:type where xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance".
> 
> 
> Sure, that's the type I'm talking about. The intended effect seems some
> crazy sort of polymorphism where we declare a sequence where one element
> can be any element derived by extension from complextype foo. Except the
> way it's setup right now only works when validated by a tired human which
> won't check it strictly, and automated parser disagree with it strongly.
> 
> Maybe instead of trying to fix the way it's declared now it'd be easier to
> do it the right way (if such a thing can be made to fly in an xml schema)
> 
> Regards,
> 

Received on Monday, 11 April 2005 09:43:23 UTC