Re: [xml] xml schema validation and xmlns attribute



Hi,

hi hi,

I've got a very basic problem with schema validation. Below are minial
example
files.
Any ideas? And sorry if it is not libxml releated and just my failure in
understanding xml schema.

Stefan

-- case1
xmllint --noout --schema ./schema1.xsd ./doc1.xml
./doc1.xml validates

-- case2
xmllint --noout --schema ./schema1.xsd ./doc2.xml
./doc2.xml:2: element buzztard: Schemas validity error : Element buzztard
not
declared
./doc2.xml:2: element buzztard: Schemas validity error : Element buzztard
not
declared
./doc2.xml fails to validate

-- case3
xmllint --noout --schema ./schema2.xsd ./doc2.xml
./schema2.xsd:3: element attribute: Schemas parser error : Element
'attribute',
attribute 'name' ['NCName']: The value must not match 'xmlns'.



--- doc1.xml
<?xml version="1.0" encoding="UTF-8"?>
<buzztard/>

--- doc2.xml
<?xml version="1.0" encoding="UTF-8"?>
<buzztard xmlns="http://buzztard.sourceforge.net"/>

-- schema1.xsd
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema";>
 <xsd:element name="buzztard" type="xsd:string"/>
</xsd:schema>

-- schema2.xsd
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema";>
 <xsd:attribute name="xmlns" type="xsd:string"/>
 <xsd:element name="buzztard">
       <xsd:complexType>
           <xsd:attribute ref="xmlns"/>
       </xsd:complexType>
   </xsd:element>
</xsd:schema>


xmllint --version
xmllint: using libxml version 20612
  compiled with: DTDValid FTP HTTP HTML C14N Catalog XPath XPointer
XInclude
Iconv Unicode Regexps Automata Schemas

Case 2 fails correctly, since the instance element <buzztard> is bound to
a namespace with the "URI http://buzztard.sourceforge.net";, but is not
declared to be in any namespace.

Case 3 fails correctly due to [1]. I think this is a reasonable 
restriction, since the place of namespace declarations might not be
under control if DOM operations are performed on the tree; have a look
at the DOM namespace normalization algorithm [2], which inserts namespace
declarations where needed.

By the way: I noticed that there is a german translation for the XML Schema
spec [3]. Normally a translation gets more confusing than the original, and
since the original already is, I can only wish the very best to people 
reading the german version.

[1] http://www.w3.org/TR/xmlschema-1/#no-xmlns
[2]
http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/namespaces-algorithms.html
[3] http://www.edition-w3c.de/TR/2001/REC-xmlschema-1-20010502/

Greetings,

Kasimier

PS: Anyone iterested in my "Dialog 1+2" books (Stanislaw Lem) in polish
for free? Once upon a time I thought I could read polish good enough, but
there is definetely a difference between The Hobbit in polish and those
two. This is not a joke, I'll throw them away otherwise. And excuse me for
being a bit private here on the list.



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]