[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Data not displaying in HTML table...generated from XML
Hi I am quite new to XML and XSL and still make frequent XSL mistakes. I often can't see why my output to HTML doesn't produce what I want. Here is my latest little puzzle: Here is the XML file being processed and one example XML file that the document funtion points to: all-links-master-list.xml <?xml version="1.0" encoding="ISO-8859-1"?> <page-links xmlns:dc="http://purl.org/dc/elements/1.1/"> <page-link filename="american-factfinder.xml"/> <page-link filename="ask-eric.xml"/> <page-link filename="biog-com.xml"/> <page-link filename="bur-just-stats.xml"/> <page-link filename="bureau-labor-stats.xml"/> <page-link filename="bus-stats-web.xml"/> <page-link filename="cal-dept-finance.xml"/> <page-link filename="calif-crime-index.xml"/> <page-link filename="calif-city-profiles.xml"/> </page-links> one example file... american-factfinder.xml <?xml version="1.0"?> <metadata xmlns:dc="http://purl.org/dc/elements/1.1/"> <dc:title> American FactFinder </dc:title> <dc:creator> U.S. Census Bureau </dc:creator> <dc:description> Population, housing, economic and geographic data from Census 2000, the 1990 Census, the 1997 Economic Census, the Census 2000 Supplementary Survey, and the American Community Survey </dc:description> <dc:date> 20030904 viewed bw </dc:date> <dc:type> Text </dc:type> <dc:format> text/html </dc:format> <dc:format> 34504 bytes </dc:format> <dc:identifier>http://factfinder.census.gov/servlet/BasicFactsServlet</dc:identifier> <dc:relation type="IsPartof">stat-openpg.htm</dc:relation> <dc:relation type="IsPartof">stat-gensit.htm</dc:relation> <dc:relation type="IsPartof">stat-pop.htm</dc:relation> <name-of-xml-file>american-factfinder.xml</name-of-xml-file> </metadata> Here is the XSL file... all-links-master-list.xsl <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns:dc="http://purl.org/dc/elements/1.1"> <xsl:output method="html"/> <xsl:template match="/"> <html> <body> <table width="95%" border="1" cellspacing="1" cellpadding="5"> <tr bgcolor="yellow"> <th>URL</th> <th>Name</th> <th>Name of XML file</th> <th>Included on page:</th> </tr> <xsl:for-each select="/page-links/page-link"> <xsl:apply-templates select="document(@filename)/metadata"/> </xsl:for-each> </table> </body> </html> </xsl:template> <xsl:template match="metadata"> <xsl:for-each select="/page-links/page-link"> <xsl:apply-templates select="document(@filename)/metadata"/> </xsl:for-each> <tr> <td><xsl:value-of select="dc:identifier"/></td> <td><xsl:value-of select="dc:title"/></td> <td><xsl:value-of select="name-of-xml-file"/></td> <td><xsl:for-each select="dc:relation"><xsl:value-of select="."/><br/></xsl:for-each></td> </tr> </xsl:template> </xsl:stylesheet> and the resulting HTML file: all-links-master-list.htm <html xmlns:dc="http://purl.org/dc/elements/1.1"> <body> <table width="95%" border="1" cellspacing="1" cellpadding="5"> <tr bgcolor="yellow"> <th>URL</th> <th>Name</th> <th>Name of XML file</th> <th>Included on page:</th> </tr> <tr> <td></td> <td></td> <td>american-factfinder.xml</td> <td></td> </tr> <tr> <td></td> <td></td> <td>ask-eric.xml</td> <td></td> </tr> <tr> <td></td> <td></td> <td>biog-com.xml</td> <td></td> </tr> <tr> <td></td> <td></td> <td>bur-just-stats.xml</td> <td></td> </tr> <tr> <td></td> <td></td> <td>bureau-labor-stats.xml</td> <td></td> </tr> <tr> <td></td> <td></td> <td>bus-stats-web.xml</td> <td></td> </tr> <tr> <td></td> <td></td> <td>cal-dept-finance.xml</td> <td></td> </tr> <tr> <td></td> <td></td> <td>calif-crime-index.xml</td> <td></td> </tr> </table> </body> </html> As you can see, it gets one table data correct in each row, but not the other ones. Can someone please help me figure this out? I have looked at this for quite a long time and can't see the mistake. And again, being new at this, I have probably done some inefficient XSL thing which may not be "best practice" or is redundant or something. Please let me know the best way to approach this and fix it. Thanks to anyone who has a little time and would like to do the diagnosis. I would think any old-time XSL wizards will spot the problem right away. --Bill Walker Reference Dept. Stockton-San Joaquin County Public Library XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|