1
votes

When I validate the following xml:

<?xml version="1.0" encoding="UTF-8"?>
<AvailRateUpdateRQ xmlns="http://www.expediaconnect.com/EQC/AR/2011/06"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
  xsi:schemaLocation="http://www.expediaconnect.com/EQC/AR/2011/06  ./XSD/AvailRateUpdateRQ.xsd">
  <Authentication username="user" password="ECLPASS"/>
  <Hotel id="111"/>
  <AvailRateUpdate>
    <DateRange from="2012-04-05" to="2012-04-07"/>
    <RoomType id="01">
      <Inventory totalInventoryAvailable="10"/>
      <RatePlan id="52ASD">
        <Rate currency="EUR">
          <PerDay rate="185.00"/>
        </Rate>
        <Restrictions minLOS="2" maxLOS="3" closedToArrival="true"/>
      </RatePlan>
    </RoomType>
  </AvailRateUpdate>
</AvailRateUpdateRQ>

using this schema:

<?xml version="1.0" encoding="UTF-8"?>
<!-- Copyright 2011 Expedia, Inc. All Rights Reserved -->
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" 
  xmlns="http://www.expediaconnect.com/EQC/AR/2011/06" 
  targetNamespace="http://www.expediaconnect.com/EQC/AR/2011/06" 
  elementFormDefault="qualified" 
  attributeFormDefault="unqualified" 
  version="2.0.0">

  <xs:element name="AvailRateUpdateRQ">
      <xs:complexType>
         <!-- Definitions of some other element there -->
      </xs:complexType>
  </xs:element>

I get this error:

Error: 1845 Element 'AvailRateUpdateRQ': No matching global declaration available for the validation root.

3
Works for me - using Visual Studio 2010 for the validation. The xsi:schemaLocation in your XML file looks wrong - but maybe is just a typing problem?MiMo

3 Answers

4
votes

I ran into a similar issue. Are you manually generating your XML? I was, and the problem was that while I added xmlns="Shema Info", that didn't actually set up the name space on the root node the same way as the parser does when reading in a file. So my generated root node wasn't in a name space, so it didn't match the root node in the validating schema.

I was using libxml2, so the calls were different. But when setting an xmlns attribute on a node, I instead did:

ns = xmlNewNs(par, val, NULL);
xmlSetNs(par, ns);

par is the parent, and val is the namespace url. I'm not sure if the par parameter is needed for the first call.

0
votes

Really very funny.

$dom->loadXML($dom->saveXML) - this a part of code which help me in my problem.

0
votes

Try using the \XMLReader for validation, instead of the \DOMDocument.