Re: [xml] xml schema validation and xmlns attribute


hi hi,

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


-- 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
./doc2.xml:2: element buzztard: Schemas validity error : Element buzztard
./doc2.xml fails to validate

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

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

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

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

-- schema2.xsd
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="";>
 <xsd:attribute name="xmlns" type="xsd:string"/>
 <xsd:element name="buzztard">
           <xsd:attribute ref="xmlns"/>

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

Case 2 fails correctly, since the instance element <buzztard> is bound to
a namespace with the "URI";, 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.




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]