Now in XML Tutorial we will learn that
XML Compilation depends on its validity and simple web browser can never show
its full fledge validity. For the proper compilation of an XML document we
need some kind of structural material that tells us about the structure of an
XML document. And on behalf of that's pre-defined structure we can validate an
XML document.
Many applications process XML based on a formal specification, expressed as XML Schema.
In XML Schema section XSD we will learn how to make an structural
document for an XML file. Simply XML Schema defines the XML structure and
on behalf of this schema we will validate an XML document. This processes
of compilation or validation of an XML document is possible only with the
help of such schemas our browsers cant validate XML document structure, it can
only some standards of XML document creation. The compiler does only support namespace schemas. It is
possible, but generally seen as weakness, to make schemas which do not use
namespaces. The provided schema is not validated! In many cases,
compile-time and run-time errors will get reported. On the other hand, the
processed data is strictly validated, both input and output will follow the
specs closely.
An XML document can be validate on some of these mentioned rules.
An XML documents must have a root element and we hope you have an idea of
root. Root is the basic starting tag in xml document and all the other
XML elements must be nested in a XML root element. As in above example XML document
code
<globalGuideLine> is the root element for that XML document.
In
HTML some times if we do not close any opened tag then it would not
effect the entire page or document but here in XML elements must have a closing tag
and the order must not effect mean the proper closing is must.
As we know in
HTML tags
these are not case sensitive but in XML, Tags are case sensitive
we need to use the same convention for opening and closing XML tags else our
document will fails on its compilation. Like <gender> and <Gender>
both are not equals in XML. If we opened <gender> we will close it
with </gender> tag.
XML elements must be properly nested suppose we opened the <firstName> and
we will close it first then we will open other tag like <lastName> else if
we open a nested tag in between <firstName> then we will close that tag
before the closing of <firstName> like <firstName>Austin
<gender>m</gender></firstName>
Even in XML document as we said that it is not a good convention to use XML
Attributes. Bit if else we use XML attributes then values of the
attributes must always be quoted in similar quotes.
Like
<firstName
gender='m'>Austin</firstName>
OR
<firsrName
gender="m">Austin</firstName>
both are valid and will be compile
successfully.