indiWiz.com
SiteSearch:
Jump:

Site Map | WizTools.org | jCraze Blog
Web Developer's Den!
Home : WDD : XML
This Article...
Print Version
Add Comment
View Comments
XML
XML - The Bare Facts
XML - Example
Working Of XML Parsers
XHTML - The Bare Facts
Java XML Technologies
Sections

Commniquè
Sign Guestbook!
Read Guestbook!
MailMe!

XML Example

The XML File (bolly.xml)

<?xml version="1.0" standalone="no"?>
<?xml-stylesheet type="text/xsl" href="bolly.xsl"?>
<!DOCTYPE bollywood SYSTEM "bolly.dtd">
<!-- Bollywood Definition Language -->
<!--My List of Favorite Bollywood Personalities-->
<bollywood>

<personality type="actress">
<name>Manisha Koirala</name>
<text>
Koirala, the nymph who destroyed my sleep... This girl displays a childish innocence and vulnerabality in her acting. This childishness combined with her revealing clothes, feminine movements, jutkhas and seductive glances create a fetish longing in the viewer's dil. But this is not to say that her acting is cliched. Her skills emcompass the whole gamut of human emotions. 3 cheers for this Nepali Belle!!
For the first time after 60s and Zeenath Amman, the neck line of a bollywood actress has gone so far down...(in the movie Chuppa Rustam), our nymph places a rose in her cleavage and continues her dance. Heck, these girls know how to seduce!!!
</text>
<song>Bungla Gaadi</song>
<film>Chuppa Rustam</film>
</personality>

<personality type="actor">
<name>Akshay Kumar</name>
<text>
The playboy of Bollywood!
</text>
<film>Mohra</film>
<song>Tu Cheeze Badi Hai Mast Mast</song>
</personality>

</bollywood>

The DTD file (bolly.dtd)

<!--DTD For Sample Document-->
<!ELEMENT bollywood (personality)>
<!ELEMENT personality (name,text,song,film)>
<!ATTLIST personality type (actor|actress) "actress">
<!ELEMENT name (#PCDATA)>
<!ELEMENT text (#PCDATA)>
<!ELEMENT song (#PCDATA)>
<!ELEMENT film (#PCDATA)>

The XSL File (bolly.xsl)

<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="/">
<html>
<body>
<table border="1" bgcolor="yellow">
<tr>
<th>Name</th><th>Text</th><th>FavSong</th><th>FavFilm</th>
</tr>
<xsl:for-each select="bollywood/personality">
<tr>
<td><xsl:value-of select="name"/></td>
<td><xsl:value-of select="text"/></td>
<td><xsl:value-of select="song"/></td>
<td><xsl:value-of select="film"/></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>

Files: bolly.xml | bolly.dtd | bolly.xsl

The HTML file created after XSLT transformation is available here: bolly.html. XSLT transformation was done using JAXP 1.1 using this Java code: XSLTransform.java.


User Comments

Add Comment

[Quick Stats: Number of main threads: 1, Number of sub-threads: 0]


Sign Guestbook | Who is Subhash?
The contents of this site are copyright© 2000-2008, indiWiz.com. All Rights Reserved.