Formatting Text with XML


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 5 of 5

Thread: Formatting Text with XML

  1. #1
    Liz Guest

    Formatting Text with XML


    Here is my Dalai Lama, I am working with sending reports from a Unix back-end
    to a Portal for publishing. The portal people tell me that I can specify
    my font scaling, margins and page layout by using an XML. Needless to say,
    they don't know how, but they know it can be done. I understand the fundamentals
    of xml but I am still missing the boat. I understand there is a style sheet
    (DTD) but, I haven't seen any examples of people defining formatting. Does
    anyone have any information on XML tags and how formatting works?


  2. #2
    Anas Shaik Mohammed Guest

    Re: Formatting Text with XML


    here is a basic XML data:

    <?xml version="1.0"?>
    <?xml-stylesheet href="table.xsl" type="text/xsl"?>
    <periodic-table>
    <atom state="gas">
    <name>Hydrogen</name>
    <symbol>H</symbol>
    <atomic-number>1</atomic-number>
    <atomic-weight>100</atomic-weight>
    <melting-point units="kelvin">13.81</melting-point>
    </atom>
    <atom state="gas">
    <name>Oxygen</name>
    <symbol>O</symbol>
    <atomic-number>2</atomic-number>
    <atomic-weight>200</atomic-weight>
    </atom>
    </periodic-table>

    Now if you want to render it you need to use XSL.This is the strength of
    the XML/XSL combi.For the same data you can create n number of rendering.

    <?xml version="1.0"?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:template match="/">
    <html>
    <head>
    <title>Atomic Number vs Atomic Weight</title>
    </head>
    <body>
    <xsl:apply-templates select="periodic-table"/>
    </body>
    </html>
    </xsl:template>

    <xsl:template match="periodic-table">
    <h1> Atomic Number VS melting point </h1>
    <table cellpadding="5">
    <th>Element</th>
    <th>Atomic Number</th>
    <th>Melting point</th>
    <xsl:for-each select="atom[atomic-number &lt; 3]">
    <tr>
    <td><xsl:value-of select="atomic-number"/></td>
    <td><xsl:value-of select="melting-point"/></td>
    </tr>
    </xsl:for-each>
    </table>
    </xsl:template>
    </xsl:stylesheet>

    XSLT programmers guide by Micheal Cay will be defenitly an asset.


    Anas


  3. #3
    Sonny Guest

    Re: Formatting Text with XML


    If you know HTML, just read the "XML Bible" by Elliotte Rusty Harold. This
    is a comprehensive book and lot of examples.

    "Liz" <my__lizard@altavista.com> wrote:
    >
    >Here is my Dalai Lama, I am working with sending reports from a Unix back-end
    >to a Portal for publishing. The portal people tell me that I can specify
    >my font scaling, margins and page layout by using an XML. Needless to say,
    >they don't know how, but they know it can be done. I understand the fundamentals
    >of xml but I am still missing the boat. I understand there is a style sheet
    >(DTD) but, I haven't seen any examples of people defining formatting. Does
    >anyone have any information on XML tags and how formatting works?
    >



  4. #4
    Geo Washington Guest

    Re: Formatting Text with XML


    Anas, does this style sheet work?
    All I see are the title, h1 and table headers.

    "Anas Shaik Mohammed" <ANASMOHAMMED@OCIWEB.COM> wrote:
    >
    >here is a basic XML data:
    >
    ><?xml version="1.0"?>
    ><?xml-stylesheet href="table.xsl" type="text/xsl"?>
    ><periodic-table>
    > <atom state="gas">
    > <name>Hydrogen</name>
    > <symbol>H</symbol>
    > <atomic-number>1</atomic-number>
    > <atomic-weight>100</atomic-weight>
    > <melting-point units="kelvin">13.81</melting-point>
    > </atom>
    > <atom state="gas">
    > <name>Oxygen</name>
    > <symbol>O</symbol>
    > <atomic-number>2</atomic-number>
    > <atomic-weight>200</atomic-weight>
    > </atom>
    ></periodic-table>
    >
    >Now if you want to render it you need to use XSL.This is the strength of
    >the XML/XSL combi.For the same data you can create n number of rendering.
    >
    ><?xml version="1.0"?>
    ><xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    ><xsl:template match="/">
    > <html>
    > <head>
    > <title>Atomic Number vs Atomic Weight</title>
    > </head>
    > <body>
    > <xsl:apply-templates select="periodic-table"/>
    > </body>
    > </html>
    ></xsl:template>
    >
    ><xsl:template match="periodic-table">
    > <h1> Atomic Number VS melting point </h1>
    > <table cellpadding="5">
    > <th>Element</th>
    > <th>Atomic Number</th>
    > <th>Melting point</th>
    > <xsl:for-each select="atom[atomic-number < 3]">
    > <tr>
    > <td><xsl:value-of select="atomic-number"/></td>
    > <td><xsl:value-of select="melting-point"/></td>
    > </tr>
    > </xsl:for-each>
    > </table>
    ></xsl:template>
    ></xsl:stylesheet>
    >
    >XSLT programmers guide by Micheal Cay will be defenitly an asset.
    >
    >
    >Anas
    >



  5. #5
    Valerie Guest

    Re: Formatting Text with XML


    Check out www.xml.com for info on XML.

    "Liz" <my__lizard@altavista.com> wrote:
    >
    >Here is my Dalai Lama, I am working with sending reports from a Unix back-end
    >to a Portal for publishing. The portal people tell me that I can specify
    >my font scaling, margins and page layout by using an XML. Needless to say,
    >they don't know how, but they know it can be done. I understand the fundamentals
    >of xml but I am still missing the boat. I understand there is a style sheet
    >(DTD) but, I haven't seen any examples of people defining formatting. Does
    >anyone have any information on XML tags and how formatting works?
    >





Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center