RE: [xsl] Data not displaying in HTML table...generated from XML

Subject: RE: [xsl] Data not displaying in HTML table...generated from XML
From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx>
Date: Wed, 29 Oct 2003 12:18:28 -0500
Bill,

Didn't I find a typo in your code yesterday?

When I fixed the typo, it worked.

See http://www.biglist.com/lists/xsl-list/archives/200310/msg01177.html

Cheers,
Wendell

See At 07:19 PM 10/28/2003, you wrote:
Hi.

Thank you for looking at this for me...

Here is what I would like the HTML output to look like (just a simple
table that
pulls the information from the individual XML files like
american-factfinder.xml etc.)

<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>http://factfinder.census.gov/servlet/BasicFactsServlet</td>
            <td>American FactFinder</td>
            <td>american-factfinder.xml</td>
            <td>stat-openpg.htm<br>
                stat-gensit.htm<br>
                stat-pop.htm</td>
         </tr>

  <tr>
            <td>http://ericir.syr.edu/</td>
            <td>  AskEric: U.S. Dept. of Education, Educational
Resources
    Information Center</td>
            <td>ask-eric.xml</td>
            <td>stat-educ.htm</td>
         </tr>


</table>



<P> .etc </body> </html>

I had it working a couple of days ago, but somehow lost the
XSL file that made it work.

In recreating it, I know Iam still doing something wrong.

Thanks again...Bill Walker

>>> mhk@xxxxxxxxx 10/28/03 03:43PM >>>
A path expression beginning with "/" selects the root node of the
document containing the context node. In your template with
match="metadata", the expression "/page-links" will not select
anything.

Define a global variable <xsl:variable name="root" select="/"/> and
then
use $root/page-links, which will get you back to the principal source
document whatever you are currently processing.

But if you do that, then this:

<xsl:template match="metadata">
 <xsl:for-each select="$root/page-links/page-link">
     <xsl:apply-templates select="document(@filename)/metadata"/>
 </xsl:for-each>

is going to give you an infinite loop. I don't actually know what you
are trying to achieve here.

Michael Kay


> -----Original Message----- > From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx > [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of > Bill Walker > Sent: 28 October 2003 18:36 > To: XSL-List@xxxxxxxxxxxxxxxxxxxxxx > Subject: [xsl] 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/BasicFacts
> Servlet</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

>


XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list


XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list


======================================================================
Wendell Piez                            mailto:wapiez@xxxxxxxxxxxxxxxx
Mulberry Technologies, Inc.                http://www.mulberrytech.com
17 West Jefferson Street                    Direct Phone: 301/315-9635
Suite 207                                          Phone: 301/315-9631
Rockville, MD  20850                                 Fax: 301/315-8285
----------------------------------------------------------------------
  Mulberry Technologies: A Consultancy Specializing in SGML and XML
======================================================================


XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list



Current Thread