Solved

Generating an HTML table with links without using data islands

Posted on 2004-09-05
6
269 Views
Last Modified: 2008-02-01
Hello!
  A number of people have asked similar questions to mine, but I find I still need help. So- here is my problem.
  I want to make an HTML table that will allow users to access a number of different related files for a number of different recordings I have.  A simplified version of my table would like like:

Filename      (WAV)     (MP3)    Text (Unicode)        Text (TIF image)       Text (JPG)   Details
Recording 1   WAV       MP3       Unicode Text           TIFF Image               JPG             Details
Recording 2   WAV       MP3       Unicode Text           TIFF Image               JPG             Details

I want each bit of text (except for the filename) to link to a file on the website, so that WAV would link (obviously) to a WAV version of the recording, and the JPG link would let users see a scanned image of accompanying text.
 
Here is the XML file that I am trying to generate this from (the first few entries, anyway):

<?xml version="1.0">
<metadata>

<item>
<filename_audio>GLSword-list.1996.01</filename_audio>
<filename_wav>GLSword-list.1996.01.wav</filename_wav>
<filename_mp3>GLSword-list.1996.01.mp3</filename_mp3>
<xml_unicode>GLSword-list.1997.01.xml</xml_unicode>
<html_unicode>GLSword-list.1997.01.htm</html_unicode>
<unicode_entries>1 - 38</unicode_entries>
<filename_image>GLSword-list.1996.01</filename_image>
<image_tif>GLSword-list.1996.01.tif</image_tif>
<image_jpg>GLSword-list.1996.01.jpg</image_jpg>
<details>GLSrecord_details.xml</details>
</item>

<item>
<filename_audio>GLSword-list.1996.02</filename_audio>
<filename_wav>GLSword-list.1996.02.wav</filename_wav>
<filename_mp3>GLSword-list.1996.02.mp3</filename_mp3>
<xml_unicode>GLSword-list.1997.01.xml</xml_unicode>
<html_unicode>GLSword-list.1997.01.htm</html_unicode>
<unicode_entries>39 - 80</unicode_entries>
<filename_image>GLSword-list.1996.02</filename_image>
<image_tif>GLSword-list.1996.02.tif</image_tif>
<image_jpg>GLSword-list.1996.02.jpg</image_jpg>
<details>GLSrecord_details.xml</details>
</item>

<item>
<filename_audio>GLSword-list.1996.03</filename_audio>
<filename_wav>GLSword-list.1996.03.wav</filename_wav>
<filename_mp3>GLSword-list.1996.03.mp3</filename_mp3>
<xml_unicode>GLSword-list.1997.01.xml</xml_unicode>
<html_unicode>GLSword-list.1997.01.htm</html_unicode>
<unicode_entries>81 - 121</unicode_entries>
<filename_image>GLSword-list.1996.03</filename_image>
<image_tif>GLSword-list.1996.03.tif</image_tif>
<image_jpg>GLSword-list.1996.03.jpg</image_jpg>
<details>GLSrecord_details.xml</details>
</item>

<item>
<filename_audio>GLSword-list.1996.04</filename_audio>
<filename_wav>GLSword-list.1996.04.wav</filename_wav>
<filename_mp3>GLSword-list.1996.04.mp3</filename_mp3>
<xml_unicode>GLSword-list.1997.01.xml</xml_unicode>
<html_unicode>GLSword-list.1997.01.htm</html_unicode>
<unicode_entries>122 - 160</unicode_entries>
<filename_image>GLSword-list.1996.04</filename_image>
<image_tif>GLSword-list.1996.04.tif</image_tif>
<image_jpg>GLSword-list.1996.04.jpg</image_jpg>
<details>GLSrecord_details.xml</details>
</item>
   
</metadata>  

So, after my table is generated, I would want the first WAV link to link to "GLSword-list.1997.01.wav" (the <filename_audio> element of the first item), the first MP3 to link to GLSword-list.1997.01.mp3, etc.

I've been able to do this with data islands, but discovered to late that browsers that aren't Windows Internet Explorer don't support data islands.

Thanks in advance for your help!
0
Comment
Question by:adulcimist
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
6 Comments
 
LVL 5

Expert Comment

by:conorj
ID: 11988475
Is this what you want?? Obviously, you will want to change the CSS styling to suit your needs, etc, etc

..............
<xsl:template match="/">
    <table>
        <thead>
            <tr>                                
                <th>Filename</th>
                <th>(WAV)</th>
                <th>(MP3)</th>
                <th>Text (Unicode)</th>
                <th>Text (TIF image)</th>
                <th>Text (JPG)</th>
                <th>Details</th>
            </tr>
        </thead>
        <tbody>
            <xsl:apply-templates select="metadata/item" />
        </tbody>
    </table>
</xsl:template>

<xsl:template match="item">
    <tr>
        <td><xsl:value-of select="filename_audio" /></td>
        <td><a href="filename_wav"><xsl:value-of select="filename_wav" /></a></td>
        <td><a href="filename_mp3"><xsl:value-of select="filename_mp3" /></a></td>
        <td><a href="html_unicode"><xsl:value-of select="html_unicode" /></a></td>
        <td><a href="image_tif"><xsl:value-of select="image_tif" /></a></td>
        <td><a href="image_jpg"><xsl:value-of select="image_jpg" /></a></td>
        <td><a href="details"><xsl:value-of select="details" /></a></td>
    </tr>
</xsl:template>
..................

rgds,
Conor.
0
 

Author Comment

by:adulcimist
ID: 11991229
Hmm...I'm afraid I'm still having trouble, but it's probably the way I'm linking your stylesheet to my document.
 Using what you typed, I made an external XSL file metadata.xsl:

<?xml version="1.0"?>

<stylesheet xmlns:xsl="http://wwww.w3.org/1999/Transform">
<xsl:template match="/">
    <table>
        <thead>
            <tr>                                
                <th>Filename</th>
                <th>(WAV)</th>
                <th>(MP3)</th>
                <th>Text (Unicode)</th>
                <th>Text (TIF image)</th>
                <th>Text (JPG)</th>
                <th>Details</th>
            </tr>
        </thead>
        <tbody>
            <xsl:apply-templates select="metadata/item" />
        </tbody>
    </table>
</xsl:template>

<xsl:template match="item">
    <tr>
        <td><xsl:value-of select="filename_audio" /></td>
        <td><a href="filename_wav"><xsl:value-of select="filename_wav"

/></a></td>
        <td><a href="filename_mp3"><xsl:value-of select="filename_mp3"

/></a></td>
        <td><a href="html_unicode"><xsl:value-of select="html_unicode"

/></a></td>
        <td><a href="image_tif"><xsl:value-of select="image_tif" /></

a></td>
        <td><a href="image_jpg"><xsl:value-of select="image_jpg" /></

a></td>
        <td><a href="details"><xsl:value-of select="details" /></a></

td>
    </tr>
</xsl:template>
</stylesheet>

And then I liked this file to my XML document by entering the line:

<?xml-stylesheet type="text/xsl" href="metadata.xsl"?>

With these changes, when I open my XML document, Internet Explorer displays only the table headers, while Netscape 7.0 and Firefox both give me:

Error loading stylesheet: Parsing an XSLT stylesheet failed.

Clearly I'm doing something wrong...
0
 

Author Comment

by:adulcimist
ID: 11991277
Addendum: After posting that, I realized that when I pasted your code into notepad, some of the lines got broken up.  That's not the problem.  I've fixed that, and still no luck.
0
How our DevOps Teams Maximize Uptime

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us. Read the use case whitepaper.

 

Author Comment

by:adulcimist
ID: 11993081
Ok- so I've gotten the stylesheet to interact properly with my xml, but when the list generates, the links don't work quite right.  right now, using

td><a href="filename_wav"><xsl:value-of select="filename_wav" /></a></td>,

the link is literally to "filename_wav" and not to the value of <filename_wav> in my XML file, which is what I need.
  Did the links reference the value properly on your computer?
0
 
LVL 5

Accepted Solution

by:
conorj earned 500 total points
ID: 11996273
OK, just spotted some typos in my original reply. All the href attributes should have curly-braces as follows:

<a href="{filename_wav}">

this is a shorthand way or writing

<a>
<xsl:attribute name="href"><xsl:value-of select="filename_wav" /></xsl:attribute>
...
</a>

rgds,
Conor.
0
 

Author Comment

by:adulcimist
ID: 11997633
Beautiful!  That's exactly what I want- the curly braces were definitely the missing bit of information that I needed.  Thanks so much!
            Patrick
0

Featured Post

Tutorials alone can't teach real engineering

So we built better training tools.

-Hands-on Labs
-Instructor Mentoring
-Scenario-Based Tests
-Dedicated Cloud Servers

All at your fingertips. What are you waiting for?

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The Problem How to write an Xquery that works like a SQL outer join, providing placeholders for absent data on the outer side?  I give a bit more background at the end. The situation expressed as relational data Let’s work through this.  I’ve …
The Confluence of Individual Knowledge and the Collective Intelligence At this writing (summer 2013) the term API (http://dictionary.reference.com/browse/API?s=t) has made its way into the popular lexicon of the English language.  A few years ago, …
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question