XML Validation error for namespace

  • Thread starter Thread starter Tatopitta
  • Start date Start date
T

Tatopitta

Hi all, it seems a stupid question, but I am stuck in it for hours!
I have an xml file with a root, namespace definition and children. Only the
root has the namespace. Other nodes are without it.

<ns0:root xmlns:ns0="http://myNamespace">
<Child1>...</Child1>
<Child2>...</Child2>
</ns:root>

I need to create a schema to validate this xml: if i use TargetNamespace,
all the nodes must have the namespace...how can I have my schema?


Thanks a lot!
 
Hi all, it seems a stupid question, but I am stuck in it for hours!
I have an xml file with a root, namespace definition and children. Only the
root has the namespace. Other nodes are without it.

<ns0:root xmlns:ns0="http://myNamespace">
<Child1>...</Child1>
<Child2>...</Child2>
</ns:root>

I need to create a schema to validate this xml: if i use TargetNamespace,
all the nodes must have the namespace...how can I have my schema?

If you'd have had an XML which had two different namespaces, then, in
general, you would need two different schemas, one importing another.

However, the case when some or all of the nested elements are in no
namespace at all (unqualified) can be handled with just one schema. In
this case, you need to restrict yourself to use only the _local_
xs:element declarations, and ensure that @elementFormDefault attribute
on your xs:schema element is not set to "qualified" (alternatively,
you may set @form attribute on individual local xs:element
declarations to "unqualified").

The XML Schema spec has an example of that - see here:
http://www.w3.org/TR/xmlschema-0/#UnqualLocals
 
Back
Top