An XML document is what is called well-formed if it meets all requirements specified by 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 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 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="">


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



This is example of not well formed or invalid namespace.

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

<root xml ="">

//Element contains more than one colon.


//Element does not have closing colon.

<ch11:valid>This is invalid



›› go to examples ››