Re: splitting into separate files and linking

Subject: Re: splitting into separate files and linking
From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx>
Date: Thu, 17 Jun 1999 21:11:24 -0700
At 99/06/17 22:22 +0100, Sebastian Rahtz wrote:
>Using XT's facilities, I have it almost working by borrowing stuff
>from James Clark:
>This works fine, making eg "N110.html" from a <div0>. The problem
>comes when I want to put in a navigation bar. James has a plausible example:
><xsl:if test="from-preceding-siblings(div0)">
>  <a href="{from-preceding-siblings(div0[1])/@name}.html">Previous
>but this uses a `name' attribute for the div0 (which I don't have, and
>don't really want), and I do not see how to get the generated-id()
>function to do its stuff in this context.

Since generate-id() has an optional node set as an argument, you can use:

<xsl:if test="from-preceding-siblings(div0)">
  <a href="{generate-id(from-preceding-siblings(div0[1]))}.html">Previous

... as in the example below.

I hope this helps.

...... Ken

T:\ftemp>type test.xml
<?xml version="1.0"?>
T:\ftemp>type test.xsl
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="";

<xsl:template match="/">                    <!--root rule-->
  <xsl:for-each select="//div0">
    <a name="{$file}">Test</a>
    <xsl:if test="from-preceding-siblings(div0)">
      <a href="{generate-id(from-preceding-siblings(div0[1]))}.html"
        >Previous article</a>


T:\ftemp>call xsl test.xml test.xsl test.htm
T:\ftemp>type test.htm
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<a name="">Test</a>
<a name="">Test</a>
<a href="N3.html">Previous article</a>
<a name="">Test</a>
<a href="N5.html">Previous article</a>


G. Ken Holman                    mailto:gkholman@xxxxxxxxxxxxxxxxxxxx
Crane Softwrights Ltd.   
Box 266, Kars, Ontario CANADA K0A-2E0   +1(613)489-0999   (Fax:-0995)
Website:  XSL/XML/DSSSL/SGML services, training, libraries, products.
Publications:   Introduction to XSLT (3rd Edition) ISBN 1-894049-00-4

 XSL-List info and archive:

Current Thread