Re: [xml] XML schema for empty NS failed to compile due to xmlns=""



On Fri, Dec 23, 2011 at 11:46:24AM +0100, Michael Ludwig wrote:
Consider the following doc and schema:

  $ cat emptyns.xml
  <Urmel>33</Urmel>

  $ cat emptyns.xsd
  <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema";>
      <xsd:element name="Urmel" type="Urmel_T"/>
      <!-- Convoluted typing just for the sake of the example -->
      <xsd:simpleType name="Urmel_T">
          <xsd:restriction base="xsd:int"/>
      </xsd:simpleType>
  </xsd:schema>

  $ xmllint --noout --schema emptyns.xsd emptyns.xml
  emptyns.xml validates

Now let's make a stupid edit to the schema file, add a redundant
xmlns="" to the top-level element. This sets the empty namespace
as the default namespace. And it is redundant because the empty
namespace already *is* the default namespace.

  $ head -1 emptyns.xsd
  <xsd:schema xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema";>

  $ xmllint --noout emptyns.xsd # parses just fine

The schema now fails to compile:

  $ xmllint --noout --schema emptyns.xsd emptyns.xml
  Element '{http://www.w3.org/2001/XMLSchema}element', attribute
  'type': References from this schema to components in the namespace
  '' are not allowed, since not indicated by an import statement.
  WXS schema emptyns.xsd failed to compile

Should I add this to the bugtracker? Or is it just too stupid to
be worthy of further attention?

  Hum, with the usual warning that I understand close to nothing to the
XSD specification, the error seems to indicate that the value of the
type attribute on the xsd:element is being checked for potential
namespace, and that the default namespace there end up applying to
"Urmel_T", and then the XSD compilation fails because that external
namespace was not declared.
  At the strict XML level that extra namespace doesn't change any of the
document structure but the interpretation of the content by the XSD
seems to be different. Someone knowing XSd well should probably chime in
and offer an educated opinion though :-)

Daniel

-- 
Daniel Veillard      | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
daniel veillard com  | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library  http://libvirt.org/



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