473,398 Members | 2,343 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

Creating HTML from an XML and XSLT

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 made
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 eight="5">Sales
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 border="0"
cellpadding="0"><tr><td>124</td>
</tr><tr><td>125</td></tr><tr><td>128</td></tr></table></td></tr></table></td></tr></table></body></html>
Apr 10 '06 #1
1 1247
Following is an example to generate HTML output using XSLT on your input xml
docuemnt.
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"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns="http://www.w3.org/1999/xhtml">
<xsl:template match="salesRep">
<html>
<body>
<table border="1">
<tr>
<td>
<xsl:value-of select="'Date'"/>
</td>
<td>
<xsl:value-of select="@orgdate"/>
</td>
</tr>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>

hope this helps,
swapna

"Thom Anderson" <th**@spamfree.net> wrote in message
news:u1**************@TK2MSFTNGP02.phx.gbl...
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 made 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 eight="5">Sales 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 border="0" cellpadding="0"><tr><td>124</td>
</tr><tr><td>125</td></tr><tr><td>128</td></tr></table></td></tr></table></t
d></tr></table></body></html>

Apr 11 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Biff Malone | last post by:
I'm creating an element at run time with the following code <xsl:variable name="myElement"> <xsl:element name="abc"> <xsl:value-of select="." /> </xsl:element> </xsl:variable> ...
4
by: TP | last post by:
Hi, I have reached a situation where I have to create small pieces of xml (around 8k characters) within my java app. Right now I am using stringbuffer to create the xml which does not go against...
2
by: Taare | last post by:
Hi, I got <xsl:output method="html" encoding="iso-8859-1" doctype-public="-//W3C//DTD HTML 4.01//EN" doctype-system=" http://www.w3.org/TR/html4/strict.dtd"/> in my XSLT file. This should remove...
4
by: sp | last post by:
Hello everybody, How can I create xsl for the following xml? ******************************************************* <?xml version="1.0"?> <result state="success"> <row> <column...
4
by: Nikhil Patel | last post by:
Hi all, I need to generate a word document and save it on the server from an ASP.Net application. Basically I want to load a word template and insert some field values from a dataset and save...
3
by: Rusty | last post by:
Hi, our intranet web site needs to add this feature. I've got the components but just need the last step to get it going. Here's the setup. 1) a user clicks on a link which calls a web service...
3
by: sham | last post by:
Hi to all, I am using XALAN processor and xslt 2.0 and I have managed to take an XML file and split it into multiple documents. This is done via the Oxygen editor. I now need to write a C#...
12
by: Chris | last post by:
Hi, Just wondering if anyone out there knows if it is possible to convert a CSV to xml using XSLT? I've seen a lot of examples of xml to CSV, but is it possible to go back the other way? I...
4
by: mark4asp | last post by:
I have an element, report which contains tags which have been transformed. E.g. <pis &lt;p&gt <myXml> <report>This text has html tags in it.&lt;p&gt which but <has been changed to &lt;&gt</report>...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.