[xsl] combination of document() and generate-id() for hyperlinks

Subject: [xsl] combination of document() and generate-id() for hyperlinks
From: jfi@xxxxxxxxxxxxxxxx
Date: Fri, 10 Jan 2003 11:50:12 +0100
Hello List,

I spent the last few hours trying to do something I consider very tricky:
I´m writing a rather large stylesheet that - among other things - reads out
attributes called "configurationPath". These configuration paths are passed
to the document-function in order to process the documents specified there.
The output is HTML.

So far so good. What I want to do now is to create hyperlinks from the base
document output (which is called base.xml) to the beginng of the other
documents'  output. And I don´t seem to be able to call the generate-id()
-function the right way, although I read the FAQ.

These are simplified versions of base.xml and the stylesheet. The position
the <a>s should appear are commented in the stylesheet.

base.xml
<?xml version="1.0"?>
<base xmlns="http://www.dummy.de";
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
             xsi:schemaLocation="http://www.dummy.de/base.xsd";>

    <stuff>
   </stuff>
   <morestuff>
   </morestuff>

   <mainApplication name="Demo" configurationPath
="product/demo/demoApplication.xml" />

   <applications>
      <application name="Tools" configurationPath
="tool/toolApplication.xml" />
      <application name="testapp" configurationPath
="test/testApplication.xml" />
   </applications>
</base>

simple.xsl
<?xml version="1.0" encoding="iso-8859-1"?>

<xsl:stylesheet
     xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; version="1.0"
     xmlns:base="http://www.dummy.de";
     xmlns:app="http://www.dummy.de/application";>

  <xsl:output method="html" encoding="iso-8859-1" indent="yes"/>
  <xsl:strip-space elements="*"/>

  <!--Root-Element-->
  <xsl:template match="/">
   <html>
    <body>
        <h1>Base configuration</h1><br/>
        <xsl:apply-templates select="base:base"/>
      <br/><h1>Application configuration</h1>
        <xsl:apply-templates select="base:base//*[@configurationPath]" mode
="apps"/>
    </body>
   </html>
  </xsl:template>

  <!--base.xml-->
  <xsl:template match="base:base">
      <table width="640">
      <xsl:apply-templates/>
      </table>
  </xsl:template>

  <xsl:template match="base:mainApplication">
    <xsl:variable name="test" select="@configurationPath"/>
    <tr>
    <td>main application</td>
<!-- Here I´d like to have a hyperlink><a>-->
    <td><xsl:value-of select="@name"/></td>
<!--</a>-->
    <td><xsl:value-of select="@configurationPath"/></td>
    </tr>
  </xsl:template>

  <xsl:template match="base:applications">
    <xsl:apply-templates/>
  </xsl:template>

  <xsl:template match="base:application">
    <tr>
<!-- Here I´d like to have a hyperlink><a>-->
      <td>application <xsl:number/></td>
<!--</a>-->
      <td><xsl:value-of select="@name"/></td>
      <td><xsl:value-of select="@configurationPath"/></td>
    </tr>
  </xsl:template>
  <!-- End of base.xml-->

  <!-- processes the applications' configuration files-->
  <xsl:template match="*[@configurationPath]" mode="apps">
    <xsl:variable name="application" select="@configurationPath"/>
    <br/>
<!-- this is were the link should refer to <a>--->
    <h2>Application <xsl:value-of select="$application"/></h2>
<!-- </a> -->
    <xsl:apply-templates select="document($application)" mode="app"/>
  </xsl:template>

  <!--application subelements-->
  <xsl:template match="app:application" mode="app">
    <xsl:apply-templates/>
  </xsl:template>

</xsl:stylesheet>

The applications' xml files can be almost empty, for testing they just need
a root-element "application"

<?xml version="1.0"?>

<application xmlns ="http://www.dummy.de/application";
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
             xsi:schemaLocation="http://www.dummy.de/application.xsd";>

</application>

  Thank you very much for your help. I really don´t know what to do.

Julia



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


Current Thread