[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

[xsl] Creating Forward/Backward HTML links from multi-file XSL processing

Subject: [xsl] Creating Forward/Backward HTML links from multi-file XSL processing
From: Randolph Kahle <randy.kahle@xxxxxxxxxxxxx>
Date: Sat, 24 Jan 2004 10:11:29 -0700

I am using XSL to translate a set of XML documents into a corresponding set of HTML documents. I am stuck trying to figure out how to create <a > ... </a> links in HTML that display forward and backward pointers through the web pages.

Each XMl document represents one "topic" in a class.

The file class.xml is:


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

<!DOCTYPE class
<!ENTITY pINTRODUCTION    SYSTEM  "introduction.xml" >
<!ENTITY pOVERVIEW        SYSTEM  "overview.xml" >
<!ENTITY pOVERVIEW2       SYSTEM  "overview2.xml" >



Each topic has the following (partial) structure:


    <!-- Used to link topics together -->
    <course>Course Name</course>

<!--- removed -->



Notice that I embed knowledge of the <next/> and <prior/> topic names into each topic file. This has allowed me to use the following code to create forward/backward pointers:


    <div id="navigation">
      <xsl:variable name="menu-prior" select="menu/prior"/>
      <xsl:value-of select="menu-prior"/>
      <xsl:if test="(menu/prior) or (menu/next)">
          <xsl:if test="menu/prior">
              <li><a href="{menu/prior}.html">prior</a></li>
          <xsl:if test="menu/next">
              <li><a href="{menu/next}.html">next</a></li>


Is there a better solution to this? I would prefer to keep the meta information about topic sequence out of each topic file.

Basically, as I understand it, I need to point backward one sibling topic and forward one sibling topic and detect the end cases where there is no forward/backward sibling.

I am stumped. Would someone mind helping me with the XPath construct(s) to do this?



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

Current Thread