Note that there are some explanatory texts on larger screens.

plurals
  1. POValidating XML: No matching global declaration available for the validation root
    primarykey
    data
    text
    <p>I'm trying to validate the following XML against a XSD schema using Ruby. It simply won't work, stops with an error message telling me </p> <blockquote> <p>Error: Element 'request': No matching global declaration available for the validation root.</p> </blockquote> <p>Maybe it's the namespace? Any ideas?</p> <h2>XML</h2> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;request type="test" xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt; &lt;channel name="channel"&gt; &lt;username&gt;user&lt;/username&gt; &lt;password&gt;pass&lt;/password&gt; &lt;/channel&gt; &lt;hotel id="1"&gt; &lt;date from="2009-07-07" to="2009-07-17"/&gt; &lt;room id="1"&gt; &lt;allocation&gt;10&lt;/allocation&gt; &lt;/room&gt; &lt;/hotel&gt; &lt;/request&gt; </code></pre> <h2>XSD</h2> <pre><code>&lt;xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt; &lt;!-- channel --&gt; &lt;xsd:element name="channel"&gt; &lt;xsd:attribute name="name" use="required" type="xsd:string" /&gt; &lt;xsd:sequence&gt; &lt;xsd:element username="name" use="required" type="xsd:string"/&gt; &lt;xsd:element password="country" use="required" type="xsd:string"/&gt; &lt;/xsd:sequence&gt; &lt;/xsd:element&gt; &lt;!-- hotel --&gt; &lt;xsd:element name="hotel"&gt; &lt;xsd:attribute name="id" use="required" type="xsd:string" /&gt; &lt;xsd:sequence&gt; &lt;xsd:element name="hotel"&gt; &lt;xsd:attribute name="from" use="required" type="xsd:string" /&gt; &lt;xsd:attribute name="to" use="required" type="xsd:string" /&gt; &lt;/xsd:element&gt; &lt;xsd:element ref="room" minOccurs="1"/&gt; &lt;/xsd:sequence&gt; &lt;/xsd:element&gt; &lt;!-- room --&gt; &lt;xsd:element name="room"&gt; &lt;xsd:sequence&gt; &lt;xsd:element name="allocation" type="xsd:string"&gt;&lt;/xsd:element&gt; &lt;xsd:element ref="hotel" minOccurs="1"/&gt; &lt;/xsd:sequence&gt; &lt;xsd:attribute name="id" use="required" type="xsd:string" /&gt; &lt;/xsd:element&gt; &lt;!-- building all together --&gt; &lt;xsd:element name="request"&gt; &lt;xsd:attribute name="type" use="required" type="xsd:string" /&gt; &lt;xsd:complexType&gt; &lt;xsd:sequence&gt; &lt;xsd:element ref="channel" maxOccurs="1"/&gt; &lt;xsd:element ref="hotel" maxOccurs="1"/&gt; &lt;/xsd:sequence&gt; &lt;/xsd:complexType&gt; &lt;/xsd:element&gt; &lt;/xsd:schema&gt; </code></pre> <h2>Ruby code</h2> <pre><code>require "xml" document = LibXML::XML::Document.file("/tmp/test.xml") schema = LibXML::XML::Document.file("/tmp/request.xsd") result = document.validate_schema(schema) do |message,flag| log.debug(message) puts message end </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload