XML
  Home arrow XML arrow Page 6 - Introduction to Cocoon, XML XSL
Dev Shed Forums 
Administration  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Forums Sitemap 
IBM® developerWorks 
Dedicated Servers 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
Download TestComplete 
VPS Hosting 
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
XML

Introduction to Cocoon, XML XSL
By: Olivier Eymere
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 3 stars3 stars3 stars3 stars3 stars / 8
    2001-03-22

    Table of Contents:
  • Introduction to Cocoon, XML XSL
  • Getting the tools
  • Installing Tomcat
  • Installing Cocoon
  • Defining your document
  • Creating your xml file
  • Viewing your document in an HTML browser
  • Viewing your document in a WAP browser
  • Viewing your file as a pdf

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
     
    ADVERTISEMENT

    PCmover - $15 Off with Coupon Code CJPH7Q

    Introduction to Cocoon, XML XSL - Creating your xml file
    (Page 6 of 9 )

    Now that we know what our data should look like we create the xml file. According to the dtd our xml file must contain all of these elements in (more or less) this structure:

    <contact> <name> <first-name></first-name> <last-name></last-name> </name> <address> <street></street> <city></city> <state></state> <country></country> </address> <phone></phone> <e-mail></e-mail> </contact>

    To begin create a file called homer.xml and open it in a text editor. The first line of the xml file is the XML declaration:


    <?xml version="1.0"?>

    Every xml and xsl document should begin with the XML declaration. This declares that this is an xml document and which version of xml you are using.

    Tags of the form <?...?> are processing instructions (PI). Processing instructions are instructions that are passed to the application that will be using the xml document. The first word after the <? is called the target which is the application that the instructions will be passed to. The rest of the PI contains the instructions to be passed to the target. In this case the target is the xml application and we are telling it that we are using xml version 1.0.

    The next is our document type declaration. This is where we associate our xml file with the dtd we created. All declarations use the tag <!...>. The document type declaration looks like:


    <!DOCTYPE contact SYSTEM "contact.dtd">

    Next we want to add a PI for cocoon so that Cocoon knows that we want it to perform stylesheet transformations for us:


    <?cocoon-process type="xslt"?>

    Finally we can populate our file with data. At this point filling in the data is pretty simple, just add data values between the tags:


    <contact> <name> <first-name>Homer</first-name> <last-name>Simpson</last-name> </name> <address> <street>122 West 1st Avenue</street> <city>Springfield</city> <state>ZZ</state> <country>USA</country> </address> <phone>1-555-555-1111</phone> <e-mail>h.simpson@springfieldnuclear.com</e-mail> </contact>

    With properly defined dtds and an xml template filling in data should be a relatively painless task.

    More XML Articles
    More By Olivier Eymere


     

       

    XML ARTICLES

    - How to Set Up Podcasting and Vodcasting
    - Creating an RSS Reader Application
    - Building an RSS File
    - An Introduction to XUL Part 6
    - An Introduction to XUL Part 5
    - An Introduction to XUL Part 4
    - An Introduction to XUL Part 3
    - An Introduction to XUL Part 2
    - An Introduction to XUL Part 1
    - XML Matters: Practical XML Data Design and M...
    - Practical XML Data Design and Manipulation f...
    - SimpleXML
    - XForms Basics, Part 3
    - XForms Basics, Part 2
    - XForms Basics




    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway