Altova Mailing List Archives

Re: Creating HTML from an XML and XSLT

From: "swapna guddanti [MSFT]" <swapnag@---------.--->
Date: 4/10/2006 6:02:00 PM

Following is an example to generate HTML output using XSLT on your input xml
In the following xslt, I'm writing the orgdate attribute of the salesRep
node into a Date row in a table in the output.
The idea is to have your html tags interspersed with xslt. As far as xslt
code goes, you can have the top level amtch expression match salesRep node
as in
<xsl:template match="salesRep">
 and write out the xpath for the attribute /child nodes underneath it as
shown below.

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
<xsl:template match="salesRep">
      <table border="1">
            <xsl:value-of select="'Date'"/>
            <xsl:value-of select="@orgdate"/>

hope this helps,

"Thom Anderson" <thom@s...> wrote in message
> Hi, I'm a newbee at XML so I need to ask this.  I have an xml data like
> follows.
> <?xml version="1.0" encoding="utf-8" ?>
> <salesRep repnum="123" orgdate="16">
>     <fname>Joe</fname>
>     <lname>Jones</lname>
>     <active>1</active>
>     <jobtitle>Sales Manager</jobtitle>
>     <alternateRepNumbers>
>         <alternateRepNum>124</alternateRepNum>
>         <alternateRepNum>125</alternateRepNum>
>         <alternateRepNum>128</alternateRepNum>
>     </alternateRepNumbers>
> </salesRep>
> I need to display it like this but I don't know how to create a transform
> XSLT document.  Can someone create it for me so I can understand it.  I
> this example easy I think.
> <html><body><table cellSpacing="0" cellPadding="10"
> border="1"><tr><td><table border="1"><tr><td colSpan="2">Date:
> 16</td></tr><tr><td colSpan="2">Rep&nbsp;Information: Joe
> Jones</td></tr><tr><td height="5"><B>Job Title:</B></td><td
> Manager</td></tr><tr><td><B>Primary Rep
> Num:</B></td><td>123</td></tr><tr><td><B> Active
> Status:</B></td><td>Yes</td>
> </tr><tr valign="top"><td><B>Alternate Numbers</B></td><td><table
> cellpadding="0"><tr><td>124</td>


These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.