XML.com: XML From the Inside Out

XML.comWebServices.XML.comO'Reilly Networkoreilly.com
  Articles | Weblogs | Newsletter | Safari Bookshelf
advertisement

Article:
 Reading Multiple Input Documents
Subject: I don't get it!
Date: 2006-02-28 19:01:55
From: gman44

I have one DataSet.xsd with two tables and two .xml files, each table has it's own seperate xml.


DataSet1.xsd ------- datatable1 ---- datatable1.xml
^------- datatable2 ---- datatable2.xml


I need two tables on the same HTML page. I'm having difficulty coding the .xslt file. Here is what I have so far.....


I don't know how to tie each table to each template.


<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
xmlns:tbl="http://tempuri.org/DataSet1.xsd" exclude-result-prefixes="tbl">

<xsl:template match="/">
<html>
<head>
<title>Customers</title>
</head>
<body>
<h1 style=" font-family:arial; font-size:12pt; font-weight:bold; text-align:left;">Customers:</h1>
<table border="1" style="width:100%">
<thead>
<tr style =" font-family:arial; font-size:10pt; font-weight:bold; text-align:center; background-color:FAF8CC; cell-padding:10px">
<td>Date/Time</td>
<td>First Name</td>
<td>Last Name</td>
<td>Gender</td>
<td>Age</td>
</tr>
</thead>
<xsl:apply-templates/>


</table>

<h1 style=" font-family:arial; font-size:12pt; font-weight:bold; text-align:left;">Jobs:</h1>
<table border="1" style="width:100%">
<thead>
<tr style =" font-family:arial; font-size:10pt; font-weight:bold; text-align:center; background-color:FAF8CC; cell-padding:10px">
<td>Date/Time</td>
<td>Current</td>
<td>Past</td>
</tr>
</thead>
<xsl:apply-templates/>
</table>
</body>
</html>
</xsl:template>


<xsl:template match="tbl:tablecustomers">
<tr style =" font-family:arial; font-size:10pt; font-weight:normal; text-align:left; background-color:FFFFFF; cell-padding:10px">
<td>
<xsl:value-of select="tbl:datetime"/>
</td>
<td>
<xsl:value-of select="tbl:firstname"/>
</td>
<td>
<xsl:value-of select="tbl:lastname"/>
</td>
<td>
<xsl:value-of select="tbl:gender"/>
</td>
<td>
<xsl:value-of-select="tbl:age"/>
<td>
</tr>
</xsl:template>


<xsl:template match="tbl:primarykey"/>



<xsl:template match="tbl:tableinfo">
<tr style =" font-family:arial; font-size:10pt; font-weight:normal; text-align:left; background-color:FFFFFF; cell-padding:10px">
<td>
<xsl:value-of select="tbl:datetime"/>
</td>
<td>
<xsl:value-of select="tbl:current"/>
</td>
<td>
<xsl:value-of select="tbl:past"/>
</td>
</tr>
</xsl:template>
<xsl:template match="tbl:primarykey"/>
</<xsl:stylesheet>


Previous Message Previous Message   Next Message Next Message


Titles Only Titles Only Newest First
  • I don't get it!
    2006-03-01 05:58:25 Bob DuCharme [Reply]

    Typically, people pass one of the input files as the source for the transformation and use the document() function to read in the other.


    For a more detailed analysis of your code and specific suggestions about wasy to fix it, you're probably best off with the XSL-list at http://www.mulberrytech.com/xsl/xsl-list/, where it will be quickly reviewed by many people who know XSLT well.


    Bob

Sponsored By:


Contact Us | Our Mission | Privacy Policy | Advertise With Us | | Submissions Guidelines
Copyright © 2008 O'Reilly Media, Inc. | (707) 827-7000 / (800) 998-9938