An XML document is what is called well-formed if it meets all requirements specified by w3.org and conforms to the XML syntax rules.  An XML document with a well-formed namespace is a valid XML document.

Well formed document rules

 A document is said well-formed namespace if it follows below rules:

  • The element and attribute names contain one or zero colon.
  • The entity names, processing instruction targets or notation names should not contain any colons.

A XML document is said to be namespace-valid, if it follows below given rules:

  • The prefixes should not be x, m, l or any combination of these letters.
  • Default namespace of prefix “xml” is http://www.w3.org/2000/xmlns/. It may or may not be declared in document, but it must not be bound to any other namespace name. Similarly, the prefix name should not be used for other namespace name and it should not be declared as the default namespace.
  • By default the prefix xmlns is bound to http://www.w3.org/2000/xmlns/. It must not be declared or undeclared. Other prefixes should not be used to bind to this namespace name.
  • The namespace prefix except xml or xmlns should be declared in namespace declaration attribute.

Example of a valid XML namespace

<root xmlns:ch11="http://www.xmlLearning.com/chapter11">

<ch11:namespace>

<ch11:valid>This is valid</ch11:valid>

</ch11:namespace>

 

This is example of not well formed or invalid namespace.

//xml prefix is assigned a non-default namespace.

<root xml ="http://www.xmlLearning.com/chapter11">

//Element contains more than one colon.

<ch11::namespace>

//Element does not have closing colon.

<ch11:valid>This is invalid

</ch11:namespace>

 

›› go to examples ››