Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can a single XML schema have multiple targetNameSpaces?

I have a complexType defined in targetNameSpace as say "http://xyz.example.com" and used in many places. Now i want to use it in my newly created XSDs with different namespace say "http://abc.example.com".


Can i do this? Or do i have to use the same namespace?

like image 585
RubyDubee Avatar asked Mar 22 '10 06:03

RubyDubee


People also ask

What is the target namespace in XML Schema?

(See Figure 1 ) XML Schema calls this particular namespace as the {target namespace}, or the namespace where the newly created elements and attributes will reside.

Can you have multiple namespaces in an XML file?

Multiple Namespaces in an XML Document In some cases, your data might contain more than one NameSpaceURI. This can be easily handled. The only difference is that you need to know how namespaces are defined and how they are associated with elements.

How to specify if a schema should have a namespace?

You can also specify whether the locally declared elements and attributes of the schema should appear qualified by a namespace, either explicitly by using a prefix or implicitly by default.

What are the strengths of XML namespaces?

It is the combination of name and namespace that makes the type unique, not the definition of it. You can import the schema that defines this type into other schemas, and you can use that complex type in XML document which contain elements from both schemas. That's the strength of XML Namespaces.


1 Answers

A schema can only have a single target namespace.

As to your specific question, if your complex type were in a different namespace, it would be a different type. It is the combination of name and namespace that makes the type unique, not the definition of it.

You can import the schema that defines this type into other schemas, and you can use that complex type in XML document which contain elements from both schemas. That's the strength of XML Namespaces.

like image 173
John Saunders Avatar answered Sep 24 '22 01:09

John Saunders