Suppose I have the following XML schema file and the following XML document file. I have two questions,
Since there is no target name space specified in XML Schema file, what namespace will Information element in?
In the XML document file, when using Information, which namespace does it belong to? Please notice in this case, I do not refer to XML Schema file from the XML document file.
XML Schema file:
<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified">
<xs:element name="Information" type="xs:string"/>
</xs:schema>
XML document file:
<?xml version="1.0" encoding="utf-8"?>
<Information>Hello XML</Information>
thanks in advance, George
The Information element will be in no namespace. To put it in a default namespace you would have to specify that namespace in the tag.
<Information xmlns="http://www.mydefaultnamespace.com">
From an Oracle article:
No Namespace
No namespace exists when there is no default namespace in scope. A {default namespace} is one that is declared explicitly using xmlns. When a {default namespace} has not been >declared at all using xmlns, it is incorrect to say that the elements are in {default >namespace}. In such cases, we say that the elements are in {no namespace}. {no namespace} >also applies when an already declared {default namespace} is undeclared.
Here's a pretty comprehensive namespace resource:
XML Namespaces FAQ
Why are you defining a Schema for no target? It does not make sense.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With