XML default namespace issue

Suppose I have the following XML schema file and the following XML document file. I have two questions:

  • Since the namespace is not specified in the XML Schema file, what namespace will the information element contain in?

  • In an XML document file when using Information, to which namespace does this belong? Please note that in this case I am not referring to the 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

+4
source share
2 answers

The information item will not contain namespaces. To put it in the default namespace, you need to specify that namespace in the tag.

 <Information xmlns="http://www.mydefaultnamespace.com"> 

From an Oracle article :

No namespace

A namespace does not exist if there is no default namespace in the scope. A {default namespace} is one that is explicitly specified using xmlns. When {default namespace} was not declared at all with xmlns, it is not true that the elements are in {default> namespace}. In such cases, we say that the elements are in {no namespace}. {no namespace}> also applies if an already declared default namespace is not defined.

Here's a pretty extensive namespace resource:

Frequently Asked Questions about XML Namespaces

+9
source

Why do you define a circuit without a goal? It does not make sense.

+1
source

All Articles