[ACCEPTED]-What is the difference between targetNamespace and xmlns:target?-xsd

Accepted answer
Score: 49

Answered quite well over here: targetNamespace and xmlns without prefix, what is the difference?

To restate:

  • targetNamespace="" - As 8 the current XML document is a schema this 7 attribute defines the namespace that this 6 schema is intended to target, or validate.

  • xmlns="" - Defines 5 the default namespace within the current 4 document for all non-prefixed elements (i.e 3 no yada: in <yada:elementName>)

  • xmlns:target="" - here you are just defining your 2 own namespace with the prefix target:, this is 1 unrelated to the previous two special cases.

Score: 8

The targetNamespace declares a namespace 6 for other xml and xsd documents to refer 5 to this schema. The target prefix in this 4 case refers to the same namespace and you 3 would use it within this schema definition 2 to reference other elements, attributes, types, etc. also 1 defined in this same schema definition.

Score: 2

The prefix "target" in xmlns:target="http://www.example.com/name" is nothing special. How 9 would a schema processor know that you wanted 8 that to be the target namespace for your 7 schema? targetNamespace does just that 6 - it declares the namespace that components 5 of your schema belong to.

N.B. Not everything 4 in the schema document goes into the targetNamespace. Note 3 attributes "elementFormDefault" and "attributeFormDefault" on 2 the "schema" element and also attribute 1 "form" on the "element" and "attribute" elements.

More Related questions