xml tutorial, what is xml, how to use xml, dtd, internal dtd, external dtd, xsl, pcdata, cdata, well formed XML document, valid XML document, tips, guide xml tutorial
(Website Helper) xml tutorial Number of Visitors: Site Map

xml tutorial



Website Design
Website Promotion
Graphic Design
Programming
Free Software
Computer Tips
Discount Stores
This site provides users with the information about xml tutorial, what is xml, how to use xml, dtd, internal dtd, external dtd, xsl, pcdata, cdata, well formed XML document, valid XML document, tips, guide, and more.

If you think that this site is helpful, please recommend your friends to visit our site.



What is xml?

XML, Extensible Markup Language, a metalanguage that allows users to define their own customized markup languages, especially in order to display documents on the World Wide Web.

Components of XML

There are three components in XML. They are dtd, XML Document, and XSL Stylesheet or XSLT Document. Now let's have a look at them one after another in the following.

1. DTD

A DTD, Document Type Definition" is the grammar that describes the structure of your XML document. It defines the acceptable XML tags for your application and their relationships. With a DTD in your XML document, you can ensure that any application which processes your data knows the purpose and structure of the tags you have created. There are two types of DTD. One is internal DTD and the other is external DTD. The follow are examples:

1) Internal DTD


<?xml version="1.0"?>
<!DOCTYPE note [
  <!ELEMENT note    (to,from,heading,body)>
  <!ELEMENT to      (#PCDATA)>
  <!ELEMENT from    (#PCDATA)>
  <!ELEMENT heading (#PCDATA)>
  <!ELEMENT body    (#PCDATA)>
]>
<note>
<to>Mary</to>
<from>>Tom</from>
<heading>Reminder</heading>
<body>Don't forget the meeting tomorrow!</body>
</note>

2) External DTD


<?xml version="1.0"?>
<!DOCTYPE note SYSTEM "note.dtd">
<note>
<to>Mary</to>
<from>Tom</from>
<heading>Reminder</heading>
<body>Don't forget this meeting tomorrow!</body>
</note> 

2. XML Document

XML is the sementics and has the role of middleman between HTML and traditional databases. It provides logical data to web applications for dynamic conversion into HTML. Together with the associated technologies of XSL, CSS, and DHTML, XML also provides the link to a web page's data and the logical description which allows it to be displayed optimally. One example is as follows:


<?xml version="1.0" encoding="iso-8859-1"?> 
<message> 
<reminder> 
<letterhead> 
<sender> Mary</sender> 
<recipient> Tom</recipient> 
<date> 2011</date> 
</letterhead> 
<text> 
<msg> Don't forget this meeting tomorrow!</msg> 
It's me Mary
</text> 
</reminder> 
</message> 

3. XSL Stylesheet or XSLT Document

XSL is used to define how the XML file should be converted so that it can seen in the required format in the Browser. If, in the XML file, we declare a Tag called:


<showbold>The Heading Text </showbold>

and you want to show the Text inside these tags in a different Font and Color. In your XSL file, you should declare it as follows:


<xsl:template match="showbold"> 
<b> 
<font color="#FF0000" face="Arial" size="3"> 
<xsl:apply-templates/> 
</font> 
</b> 
</xsl:template> 

Note:

As soon as the Tag "showbold" is encountered in the XML file, the Text is automatically replaced with Different Font size and color in bold. Also note that the tag "showbold" is not part of the standard HTML and it is a Custom Tag.

More XML information

1. Well formed XML documents contain text and XML tags which conform with the XML syntax.

2. Valid XML documents must be well formed and are additionally error checked against a Document Type Definition (DTD). A DTD is a set of rules outlining which tags are allowed, what values those tags may contain and how the tags relate to each other. Typically a valid document is used when documents require error checkin.

3. PCDATA is text that will be parsed by a parser. Tags inside the text will be treated as markup and entities will be expanded.

4. CDATA is text that will NOT be parsed by a parser. Tags inside the text will NOT be treated as markup and entities will not be expanded.

5. The + sign declares that the child element message must occur one or more times inside the note element.

6. The * sign declares that the child element message can occur zero or more times inside the note element.

7. The ? sign declares that the child element message can occur zero or one times inside the note element.

8. No sign is only once.

9. Declaring mixed content. An example as follows:


<!ELEMENT note (to+,from,header,message*,#PCDATA)> 

(Website Helper) xml tutorial (c) EduSoftMax - www.edusoftmax.com