Technology Programming

How to Convert XML to XHTML

    • 1). Design the XHTML layout within which you want to display your XML. Using graphic design programs or just a pencil and paper, sketch the appearance that you want your XML data to have when it's contained within XHTML structures. Figure out which XHTML elements you want to use in order to best present the types of data your XML contains. Remember that XHTML is more strict than HTML, and your final markup will be able to contain only four XHTML tags.

    • 2). Include a link to an XSLT document in your XML:

      <?xml-stylesheet type="text/xsl" href="/links/?u=my_style.xsl"?>

      Create a new file in a text editor and save it as "my_style.xsl" to match the reference in your XML. This is where you will list the rules that you want to apply to the XML data, and within what XHTML markup you want the XML data elements to be contained. Enter the following basic outline for your XSLT:

      <?xml version="1.0"?>

      <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

      <xsl:output method="html" omit-xml-declaration="yes" doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN" doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"/>

      </xsl:stylesheet>

    • 3). Create the basic structure of an HTML page to transform your XML elements into XHTML elements. In your XSLT, before the "</xsl:stylesheet>" line, enter the following to create a template for your document:

      <xsl:template match="/">

      </xsl:template>

      This applies to the entire XML document. Between the opening and closing "<xsl:template>" tags, enter the structure of a Web page:

      <html>

      <head></head>

      <body>

      </body>

      </html>

      This simply creates an XHTML page outline in which to present your data.

    • 4). Transform each element in your XML into an XHTML structure. In your XSLT, between the "<body>" tags, enter code to turn XML content into XHTML using the following syntax:

      <xsl:apply-templates/>

      After the "</xsl:template>" line but before "</xsl:stylesheet>" at the end of the document, enter specific instructions for your XML elements as in the following example:

      <xsl:template match="person">

      <div><xsl:apply-templates/></div>

      </xsl:template>

      This would identify an element "<person>" in the XML and present its contents within a "<div>" XHTML element.

    • 5). Test your XHTML output by opening your XML document in a Web browser. View the XHTML page source using your browser menus and extensions if you have any, checking that the structures and syntax you want are present. Validate your XHTML to check that it is well formed, as this is essential when you present XHTML content. If your XHTML does not match the design you had in mind, or has elements missing from the original XML, go back to the XSLT and reconsider its structure.

SHARE
RELATED POSTS on "Technology"
WordPress - How to Set up a New Theme to WordPress 3.
WordPress - How to Set up a New Theme to WordPress 3.
Solution of Creative Web Design
Solution of Creative Web Design
The three disciplines of User Experience
The three disciplines of User Experience
Web Design Sheffield Options For Professional Enterprises
Web Design Sheffield Options For Professional Enterprises
Do you have what it takes?
Do you have what it takes?
Segway Cost
Segway Cost
Microsoft Access 2010: What's Coming with Office 2010?
Microsoft Access 2010: What's Coming with Office 2010?
Companies of Web Development in Ireland Provide Designs that Work
Companies of Web Development in Ireland Provide Designs that Work
Penguin Update to Put Red-Flags on Negative SEO
Penguin Update to Put Red-Flags on Negative SEO
Innovative web 2 design templates can make your business famous quickly
Innovative web 2 design templates can make your business famous quickly
Building A Search Engine Friendly Website
Building A Search Engine Friendly Website
Exceptional Advice To Build Up Your Internet Marketing
Exceptional Advice To Build Up Your Internet Marketing
The Benefits of Selecting The Right Hosting Company
The Benefits of Selecting The Right Hosting Company
Is There a Methodology for Making Successful Logos
Is There a Methodology for Making Successful Logos
Benefits of Ruby On Rails Development
Benefits of Ruby On Rails Development
The Power of Colour and Shapes in Your Infant's Life.
The Power of Colour and Shapes in Your Infant's Life.
Advantages of Hiring PSD To HTML Service Providers
Advantages of Hiring PSD To HTML Service Providers
How to Make Responsive Web Design Attractive?
How to Make Responsive Web Design Attractive?
Converting PSD to Responsive HTML
Converting PSD to Responsive HTML
Just a few realy really hints and tips when it comes to website design but look for.
Just a few realy really hints and tips when it comes to website design but look for.

Leave Your Reply

*