Monday, August 20, 2007

XML Declarations

XML Declarations
Most of the XML tags have a name associated with it. Here we explain different terms used to indicate the Elements Defined in the XML file.
Well Formed Tags :
One of the Most important Features of a XML file is, it should be a Well Formed File. What it means is all the Tags should have a closing tag. In a HTML file, for some tags like
we don't have to specify a closing tag called
. Where as in a XML file, it is compulsory to have a closing tag. So we have to declare

. This are what called as Well Formed Tags.
Elements and Attributes :
Each Tag in a XML file can have Element and Attributes. Here's how a Typical Tag looks like,

In this Example, Email is called as Element. This Element called E-mail has three attributes, to, from and subject.
The Following Rules need to be followed while declaring the XML Elements Names:
Names can contain letters, numbers, and other characters
Names must not start with a number or "_" (underscore)
Names must not start with the letters xml (or XML or Xml ..)
Names can not contain spaces
Any name can be used, no words are reserved, but the idea is to make names descriptive. Names with an underscore separator are nice.
Examples: , .
Avoid "-" and "." in names. It could be a mess if your software tried to subtract name from first (author-name) or think that "name" is a property of the object "author" (author.name).
Element names can be as long as you like, but don't exaggerate. Names should be short and simple, like this: not like this: .
XML documents often have a parallel database, where fieldnames parallel with element names. A good rule is to use the naming rules of your databases.
Non-English letters like éòá are perfectly legal in XML element names, but watch out for problems if your software vendor doesn't support it.
The ":" should not be used in element names because it is reserved to be used for something called namespaces
Empty Tags :
In cases where you don't have to provide any sub tags, you can close the Tag, by providing a "/" to the Closing Tag. For example declaring
is same a declaring
Comments in XML File :
Comments in XML file are declared the same way as Comments in HTML File.
Welcome To XML Tutorial
The XML Prolog
XML file always starts with a Prolog. The minimal prolog contains a declaration that identifies the document as an XML document, like this:
The declaration may also contain additional information, like this:
The XML declaration may contain the following attributes:
version
Identifies the version of the XML markup language used in the data. This attribute is not optional.
encoding
Identifies the character set used to encode the data. "ISO-8859-1" is "Latin-1" the Western European and English language character set. (The default is compressed Unicode: UTF-8.). For a List of all supported Encoding Types in JDK 1.2 please Encodings Supported in JDK
standalone
Tells whether or not this document references an external entity or an external data type specification (see below). If there are no external references, then "yes" is appropriate
Processing Instructions
An XML file can also contain processing instructions that give commands or information to an application that is processing the XML data. Processing instructions have the following format:
where the target is the name of the application that is expected to do the processing, and instructions is a string of characters that embodies the information or commands for the application to process.

No comments: