[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Generating an HTML table with links without using data islands

Posted on 2004-09-05
6
Medium Priority
?
272 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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 2000 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

The Client Need Led Us to RSS I recently had an investment company ask me how they might notify their constituents about their newsworthy publications.  Probably you would think "Facebook" or "Twitter" but this is an interesting client.  Their cons…
Create a Windows 10 custom Image with custom task bar and custom start menu using XML for deployment.
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Suggested Courses

656 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