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

Re: [xsl] relative path from one node to another (XSLT 2.0 solution)


Subject: Re: [xsl] relative path from one node to another (XSLT 2.0 solution)
From: JBryant@xxxxxxxxx
Date: Thu, 19 May 2005 14:23:58 -0500

So, of course, two seconds after I push the send button, the light dawns 
about how to skip the delete.me junk. Since result-document will make the 
directory as it makes the files, I can skip the step of explicitly 
creating the directories. I'm having one of my more dim days, between this 
and missing the need for the self:: axis earlier. Anyway, here's the 
corrected stylesheet:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" 
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

  <!-- process the root -->
  <xsl:template match="document">
    <xsl:apply-templates>
      <xsl:with-param name="path" select="'root'"/>
    </xsl:apply-templates>
  </xsl:template>

  <!-- process the directories -->
  <xsl:template match="section[section/@display='page']">
    <xsl:param name="path"/>
    <xsl:apply-templates>
      <xsl:with-param name="path" select="concat($path, '/', @id)"/>
    </xsl:apply-templates>
  </xsl:template>

  <!-- process the pages -->
  <xsl:template 
match="section[@display='page'][not(section/@display='page')]">
    <xsl:param name="path"/>
    <xsl:result-document href="{concat($path, '/', @id, '.xml')}">
      <chunks>
        <xsl:apply-templates/>
      </chunks>
    </xsl:result-document>
  </xsl:template>

  <!-- process the inline sections -->
  <xsl:template match="section[@display='inline']">
    <content chunk="{@id}"/>
  </xsl:template>

</xsl:stylesheet>

Sorry about any confusion that may arise from double posting.

Jay Bryant
Bryant Communication Services
(presently consulting at Synergistic Solution Technologies)


Current Thread