[xsl] Retrieving urls when using document()

Subject: [xsl] Retrieving urls when using document()
From: Lynn Alford <lynn.alford@xxxxxxxxxx>
Date: Thu, 17 Nov 2005 10:55:27 +1000
I'm trying to create a nice table of contents from multiple XML files. Cruising through the FAQ, I ran across the idea of using

filelist.xml

<documents>
  <doc href="105_imp.xml"/>
  <doc href="110_vc.xml"/>
  <doc href="115_his.xml"/>
</documents>

table_of_contents.xsl

<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
  <xsl:output method="html" encoding="iso-8859-1"/>

<xsl:variable name="documents" select="document(/documents/doc/@href)"/>

<xsl:template match="/">
  <xsl:for-each select="$documents">
        <xsl:apply-templates />
    </xsl:for-each>
</xsl:template>

 <xsl:template match="Title|Table/Title">
    <p>

<a>
<xsl:attribute name="href"><xsl:value-of select="substring-before(name($documents),'.xml')"/>.html#<xsl:value-of select="."/></xsl:attribute>
<xsl:value-of select="."/>
</a>
</p>
</xsl:template>


</xsl:stylesheet>

Current output fragment

<p><a href=".html#About">About</a></p>
<p><a href=".html#Message">Message</a></p>


So this is really close to doing what I hope for but I'd like to find out if it is possible to get


<xsl:value-of select="substring-before($documents,'.xml')"/>

to reliably give me the href of the document that I'm processing in the for-each loop. Doesn't look like it should be difficult but it is stumping me.

Lynn


Lynn Alford Tel (07) 47 81 6256 ITR Email: imla@xxxxxxxxxx JCU QLD 4811 Australia ICQ: 64096907 MSN: nicarra60@xxxxxxxxxxx Y!: nicarra60

'I think an "uncatched exception" deserves three bug reports: one for the
exception, one for not catching it, and one for abuse of the English
language.'  Michael Kay

Current Thread