Jump to content

Why does ref to attribute not work?


grhodes

Recommended Posts

Hi all:I am a newbie. I have a some schemas,below, but the ref to the attribute does not seem to be inherited, or something. If I create an xml document and include and id attribute for person the xml dcoument does not validate because of that attribute. I have tried with prefixes on the attr. also. Here is my error:Attribute "id" is not allowed in element <main-ns:Person>Sample.xml<?xml version="1.0" encoding="UTF-8"?><!--Sample XML file generated by XMLSpy v2011 (http://www.altova.com)--><x:PersonBatch xsi:schemaLocation="http://Extensions Extensions.xsd" xmlns:x="http://Extensions" xmlns:main-ns="http://Main" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <main-ns:TheDate>String</main-ns:TheDate> <main-ns:Person id="001"> <main-ns:######>String</main-ns:######> </main-ns:Person> <main-ns:Person> <main-ns:######>String</main-ns:######> </main-ns:Person></x:PersonBatch>Base1.xsd<?xml version="1.0" encoding="UTF-8"?><xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:b1="http://Base1" targetNamespace="http://Base1" elementFormDefault="qualified" attributeFormDefault="unqualified"> <xs:complexType name="ObjType" abstract="true"> <xs:attribute name="idref" type="xs:string"/> <xs:attribute ref="b1:id"/> </xs:complexType> <xs:attribute name="id" type="xs:string"/></xs:schema>Base2.xsd<?xml version="1.0" encoding="UTF-8"?><xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:b1="http://Base1" xmlns:main-ns="http://Main" targetNamespace="http://Main" elementFormDefault="qualified" attributeFormDefault="unqualified"> <xs:import namespace="http://Base1" schemaLocation="Base1.xsd"/> <xs:complexType name="PetType"> <xs:complexContent> <xs:extension base="b1:ObjType"> <xs:sequence> <xs:element name="PetAnimal" type="xs:string" minOccurs="1"/> <xs:element name="PetName" type="xs:string" minOccurs="1"/> </xs:sequence> </xs:extension> </xs:complexContent> </xs:complexType> <xs:complexType name="PersonType"> <xs:complexContent> <xs:extension base="b1:ObjType"> <xs:sequence> <xs:element name="######" type="xs:string"/> </xs:sequence> </xs:extension> </xs:complexContent> </xs:complexType> <xs:complexType name="DocType"> <xs:complexContent> <xs:extension base="b1:ObjType"> <xs:sequence> <xs:element name="TheDate" type="xs:string" minOccurs="1"/> </xs:sequence> </xs:extension> </xs:complexContent> </xs:complexType> <xs:element name="Doc" type="main-ns:DocType"/> <xs:element name="Person" type="main-ns:PersonType"/> <xs:element name="Pet" type="main-ns:PetType"/></xs:schema>Extension.xsd<?xml version="1.0" encoding="UTF-8"?><xs:schema xmlns:x="http://Extensions" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:b1="http://Base1" xmlns:main-ns="http://Main" targetNamespace="http://Extensions" elementFormDefault="qualified" attributeFormDefault="unqualified"> <xs:import namespace="http://Main" schemaLocation="Base2.xsd"/> <xs:import namespace="http://Base1" schemaLocation="Base1.xsd"/> <xs:complexType name="PersonBatchType"> <xs:complexContent> <xs:extension base="main-ns:DocType"> <xs:sequence> <xs:element ref="main-ns:Person" minOccurs="2" maxOccurs="5"/> </xs:sequence> </xs:extension> </xs:complexContent> </xs:complexType> <xs:element name="PersonBatch" type="x:PersonBatchType"> <xs:annotation> <xs:documentation>Comment describing your root element</xs:documentation> </xs:annotation> </xs:element></xs:schema>

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...