xsl-list
[Top] [All Lists]

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

2005-05-20 01:19:52
This is a very elegant solution; thanks very much.

I wonder if you'd had any thoughts on the problem I described of
implementing a mechanism for linking from one output document to another
using a
<link section="tom">See Tom's page</link>
element in the source tree?

Such an element should transformed to an HTML <a> tag with the correct
'href' attribute to link from the output document in which it occurs to
the output document for the section with id 'tom'.

Cheers,
Richard
On Thu, 19 May 2005 14:23:58 -0500, JBryant(_at_)s-s-t(_dot_)com said:
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>
--~--


--~------------------------------------------------------------------
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>
--~--