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?
(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.
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.
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.
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.
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.
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