-3

And also, I don't really understand the difference between a valid document and a well formed one. Help?

Jehof
  • 34,674
  • 10
  • 123
  • 155

1 Answers1

2

When talking about XML documents, two commonly-used terms are "well formed" and "valid." As in "Is your document marked up in valid and well formed XML?"

Well formed in relation to XML means that it has no syntax, spelling, punctuation, grammar errors, etc. in its markup. These kinds of errors can cause your XML document to not parse.

Note: An XML Parser is software that reads XML documents and interprets or "parses" the code according to the XML standard. A parser is needed to perform actions on XML. For example, a parser would be needed to compare an XML document to a DTD.

In the next section, we will talk about some common errors that prevent an XML document from being well formed.

When you say an XML document is valid, you're saying that the element structure and markup of the XML document matches a defined standard of relationships, in addition to having well formed markup. In other words, is this XML document a quality document?

One standard used to validate XML is a DTD, or Document Type Declaration, although XML Schemas are also used.

These standards are useful when dealing with the creation of a number of XML documents for they provide a quality control measure to ensure that all the documents meet a minimum standard. Another benefit is that it allows for errors to be detected in the process of creating the XML document, rather than at the end. Later, we'll create a sample DTD for our email and letter XML documents.

Note: An important thing to remember is that when a document is valid it is also "well formed," but a "well formed" document is not necessarily valid. Additionally, you can create XML documents without a DTD, but the XML document can't be considered valid without a document type.

NIlesh Sharma
  • 5,445
  • 6
  • 36
  • 53