xsl-list
[Top] [All Lists]

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

2005-05-19 12:23:58
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[(_at_)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[(_at_)display='inline']">
    <content chunk="{(_at_)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)

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--