I have a problem creating a table from xml with xslt...

16 views
Skip to first unread message

Walt White

unread,
Oct 3, 2012, 2:08:42 PM10/3/12
to xs...@googlegroups.com
I have an xml file that looks like this:

<raws>
<raw id="01000P"> <--------------------------------- How do I get the id value from here using the xsl below?
<rpn>PENTB-153 TUBING, 71 CM.</rpn>
<desc/>
<datecreated/>
<status>0</status>
<mfgven>TUBING</mfgven>
<mfgvenpt>EA</mfgvenpt>
<mfgvendesc>1.170000</mfgvendesc>
<distven/>
<distvenpt>0</distvenpt>
<category>ADVANCED POLYMERS #1500</category>
</raw>
<raw id="01001P">
<rpn>PENTB-220 TUBING, 71 CM.</rpn>
<desc/><datecreated/>
<status>0</status>
<mfgven>TUBING</mfgven>
<mfgvenpt>EA</mfgvenpt>
<mfgvendesc>1.170000</mfgvendesc>
<distven/>
<distvenpt>0</distvenpt>
<category>ADVANCED POLYMERS #1500</category>
</raw>
</raws>

<?xml version="1.0" encoding="ISO-8859-1"?>
<!-- Edited by XMLSpy® -->
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="/">
<html>
<head>
<title></title>
<style type="text/css">
body { font-family: Arial, Helvetica, sans-serif; font-size:0.875em;}
#table1 {
width: 100%;
}
thead {
color: white;
text-indent: 14px;
text-align: left;
}
tbody tr:nth-child(odd) {
background-color: rgb(248, 248, 248);
}
tbody tr:nth-child(even) {
background-color: rgb(226, 239, 214);
}
</style>
</head>
<body>
<h2>RAW Dataset</h2>
<table cellspacing="0">
<tr bgcolor="E2EFD6">
<th bgcolor="#E2EFD6" align="left">RAW</th> <------------------------ I need in this column
<th bgcolor="#E2EFD6" align="left">RPN</th>
<th bgcolor="#E2EFD6" align="left">Description</th>
<th bgcolor="#E2EFD6" align="left">Date Created</th>
<th bgcolor="#E2EFD6" align="left">Status</th>
<th bgcolor="#E2EFD6" align="left">Mfg. Vendor</th>
<th bgcolor="#E2EFD6" align="left">Mfg. Vendor Part</th>
<th bgcolor="#E2EFD6" align="left">Distribution Vendor</th>
<th bgcolor="#E2EFD6" align="left">Distribution Vendor Part</th>
<th bgcolor="#E2EFD6" align="left">Category</th>
</tr>
<xsl:text>&#160;</xsl:text>
<xsl:for-each select="raws/raw">
<tr>
<td><xsl:value-of select="id"/></td> <-------------------------------- This doesn't work
<td><xsl:value-of select="rpn"/></td>
<td><xsl:value-of select="desc"/></td>
<td align="right" style="padding-right: 15px"><xsl:value-of select="datecreated"/></td>
<td><xsl:value-of select="status"/></td>
<td><xsl:value-of select="mfgven"/></td>
<td><xsl:value-of select="mfgvenpt"/></td>
<td><xsl:value-of select="distven"/></td>
<td><xsl:value-of select="distvenpt"/></td>
<td><xsl:value-of select="category"/></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>

Thanks in advance for your help

WW

mbvana

unread,
Oct 3, 2012, 2:42:18 PM10/3/12
to xs...@googlegroups.com
<td><xsl:value-of select="@id"/></td> <------------------------ You have forgot @ for parameter  id



среда, 3 октября 2012 г., 22:08:43 UTC+4 пользователь Walt White написал:

Walt White

unread,
Oct 3, 2012, 2:48:36 PM10/3/12
to xs...@googlegroups.com
Perfect! That took care of it. Thank you.
Reply all
Reply to author
Forward
0 new messages