Well Formed & Valid XML Documents?

  • Thread starter Thread starter Arpan
  • Start date Start date
A

Arpan

I came across the following statement at
http://windowssdk.msdn.microsoft.com/en-us/library/hdf992b8.aspx:

Although an XML document is considered to be well formed if it meets
all the syntactical requirements defined by the World Wide Web
Consortium (W3C) Extensible Markup Language (XML) 1.0 Recommendation,
it is not considered valid unless it is well formed and also conforms
to the constraints defined by its DTD or schema. Therefore, although
all valid XML documents are well formed, not all well-formed XML
documents are valid.

Can someone please explain me the above preferably with small examples?

Thanks,

Arpan
 
Well formed means the document follows the rules of XML. For example, every
tag is closed, properly nested, etc.

<root>
some value
</root>

is a very simple, well-formed document.

To be valid, it must conform to a contract (DTD or schema). For example, you
set up a schema that says you must have a Customers tag which contains one
or more customer tags. A customer can only have one first anme and one last
name and they must bbe filled in. If you check out a document and it has no
Customer or the first or last name is not filled out for ANY of the
customer(s) contained, it is not valid. It might stilll be technically
correct for XML, which would make it well formed.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

*************************************************
Think Outside the Box!
*************************************************
 
Thanks Gregory.....your answer to my post was very much appropriate &
to the point. It really helped me understand the difference between a
well-formed & a valid XML document.

Thanks once again,

Regards,

Arpan
 
Back
Top