Well Formed & Valid XML Documents?

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
 
C

Cowboy \(Gregory A. Beamer\)

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!
*************************************************
 
A

Arpan

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top