1
votes
  • As I understand, the namespaces in xml (and) XSD are used to mitigate the possible ambiguity of the elements and attributes referenced.
    • The attribute targetNamespace of a XML Schema is for specifiying the namespace that the elements defined in that file (or everything inside the element that has the targetNamespace) correspond to. This applies only for the elements "declared" in this context (that have their name declared in attribute "name").
    • So, if I declare a targetNamespace in my Schema, every instance I validate against it, must use that namespace before any element or attribute declared in the Schema, or declare it as the default namespace to save me from having to precede each type from that Schema with it.

If any of that is wrong, be sure to correct me.

What's driving me crazy, it's why doesn't this:

<?xml version="1.0" encoding="UTF-8"?>
<responsabilities xmlns="http://www.library.org">
<responsability>uno</responsability>
<responsability>dos</responsability>
<responsability>tres</responsability>
</responsabilities>

...validates against this:

<?xml version="1.0" encoding="UTF-8"?>
<schema targetNamespace="http://www.library.org" xmlns="http://www.w3.org/2001/XMLSchema" xmlns:bpd="http://www.library.org" >
<element name="responsabilities" type="bpd:responsabilitiesType"/>
<complexType name="responsabilitiesType">
    <sequence>
        <element maxOccurs="unbounded" name="responsability" type="string" />
    </sequence>
</complexType>
</schema>

It shows this error:

The element 'responsabilities' in namespace 'http://www.library.org' has invalid child element 'responsability' in namespace 'http://www.library.org'. List of possible elements expected: 'responsability'. Line: 1 Column:90

I validated against a SimpleType using the same namespace scheme, and had no problem at all.

Thanks.

1

1 Answers

0
votes

Nevermind:

The schema was lacking the attribute:

elementFormDefault="qualified"