'xsi:schemaLocation' is not allowed

Questions about XML that are not covered by the other forums should go here.
deniswsrosa
Posts: 1
Joined: Fri Jan 08, 2010 8:07 pm

'xsi:schemaLocation' is not allowed

Post by deniswsrosa » Fri Jan 08, 2010 8:14 pm

Hi guys!

I m wondering why I cannot put the atribute 'xsi:schemaLocation' in the root tag of my xml. Anyone can help me?

XSD

Code: Select all


<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">

<xs:simpleType name="subTransIdType">
<xs:restriction base="xs:string"/>
</xs:simpleType>

<xs:simpleType name="compositionType">
<xs:restriction base="xs:string">
<xs:pattern value="Sequential|Parallel|Alternative"/>
</xs:restriction>
</xs:simpleType>

<xs:complexType name="compositionElementType">
<xs:sequence>
<xs:element name="SubTransaction" type="subTransactionType" maxOccurs="unbounded" minOccurs="1"/>
</xs:sequence>
<xs:attribute name="compositionType" type="compositionType" use="required"/>
</xs:complexType>

<xs:complexType name="subTransactionType">
<xs:choice>
<xs:element name="WebService">
<xs:complexType>
<xs:all>
<xs:element name="ServiceDescription" type="xs:string" minOccurs="1"/>
</xs:all>

<xs:attribute name="group" type="xs:string"/>
<xs:attribute name="serviceId" type="xs:string" use="required"/>
</xs:complexType>
</xs:element>

<xs:element name="Composition" type="compositionElementType"/>
</xs:choice>
<xs:attribute name="subTransactionId" type="subTransIdType" use="required"/>
</xs:complexType>

<xs:element name="TransactionTree">
<xs:complexType>
<xs:all>
<xs:element name="SubTransaction" minOccurs="1">
<xs:complexType>
<xs:all>
<xs:element name="Composition" type="compositionElementType"/>
</xs:all>
<xs:attribute name="subTransactionId" type="subTransIdType" use="required"/>
</xs:complexType>
</xs:element>
<xs:element name="Dependencies" minOccurs="1">
<xs:complexType>
<xs:sequence>
<xs:element name="InternalDependency" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="originator" type="subTransIdType"/>
<xs:attribute name="paramName" type="xs:string" />
<xs:attribute name="dependent" type="subTransIdType"/>
<xs:attribute name="alias" type="xs:string"/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:all>
<xs:attribute name="transactionId" type="xs:string" use="required"/>
</xs:complexType>
</xs:element>
</xs:schema>

xml

Code: Select all



<?xml version="1.0" encoding="UTF-8"?>
<TransactionTree
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://ipti.org.br/flypeer/TransactionContext.xsd" transactionId="0001">
<SubTransaction subTransactionId="010">
<Composition compositionType="Sequential">
<SubTransaction subTransactionId="011">
<Composition compositionType="Alternative">
<SubTransaction subTransactionId="0111">
<WebService serviceId="LUFTHANSA-FLIGHT-BOOKING">
<ServiceDescription>
Flight Booking Service
</ServiceDescription>
</WebService>
</SubTransaction>
<SubTransaction subTransactionId="0112">
<WebService group="flight/britsh" serviceId="BA-FLIGHT-BOOKING">
<ServiceDescription>
TAM Flight Booking Service
</ServiceDescription>
</WebService>
</SubTransaction>
</Composition>
</SubTransaction>
<SubTransaction subTransactionId="012">
<WebService group="hotel" serviceId="JXTA-HOTEL-BOOKING">
<ServiceDescription>
Hotel Booking Service
</ServiceDescription>
</WebService>
</SubTransaction>
</Composition>
</SubTransaction>
<Dependencies>
<InternalDependency alias="lufth_destination" paramName="flightTarget" dependent="0111"/>
<InternalDependency alias="ba_destination" paramName="flightTarget" dependent="0112"/>
<InternalDependency paramName="hotelTarget" dependent="012"/>
<InternalDependency originator="0111" paramName="bookDate" dependent="012"/>
<InternalDependency originator="0112" paramName="bookDate" dependent="012"/>
<InternalDependency originator="0111" paramName="bookDate"/>
<InternalDependency originator="0112" paramName="bookDate"/>
<InternalDependency originator="012" paramName="hotelResp"/>
</Dependencies>
</TransactionTree>
The error is :

Code: Select all


Attribute 'xsi:schemaLocation' is not allowed to appear in element 'TransactionTree'.
Tks a lot!

Radu
Posts: 7028
Joined: Fri Jul 09, 2004 5:18 pm

Re: 'xsi:schemaLocation' is not allowed

Post by Radu » Mon Jan 11, 2010 10:41 am

Hi,

As your XML Schema has no target namespace, in the XML you have to specify the associated XSD like:

Code: Select all


xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xsi:noNamespaceSchemaLocation="http://ipti.org.br/flypeer/TransactionContext.xsd"
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com

Post Reply