xsl-list
[Top] [All Lists]

Re: [xsl] Why Are My Tunnel Parameters Not Working?

2008-03-06 08:21:13
Andrew Welch wrote:
On 06/03/2008, Eliot Kimber <ekimber(_at_)reallysi(_dot_)com> wrote:
 Can someone tell me what stupid thing I'm doing?

I glanced over it but it was also a bit too long and messy to make it
easy to follow what was going on... maybe reduce it down and repost?
Even in the unlikely event it did turn out to be a problem with Saxon,
you could'nt exactly submit that as code to reproduce the problem...

Here is a minimal form of the same script--it should be just an identify transform that maintains the original directory structure:

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

  <xsl:param name="outdir" as="xs:string" required="yes"/>
  <xsl:variable name="outdirVar"
    select="if (ends-with($outdir, '/'))
               then $outdir
               else concat($outdir, '/')"
            as="xs:string"/>

  <xsl:template match="/">
    <xsl:apply-templates>
      <xsl:with-param name="baseOutDir"
            select="$outdirVar"
            tunnel="yes"
            as="xs:string"/>
    </xsl:apply-templates>
  </xsl:template>

  <xsl:template match="topicref[(_at_)href]">
    <xsl:param name="baseOutDir" tunnel="yes"
         as="xs:string"
         required="yes"/>
    <xsl:variable name="targetUrl"
         select="@href" as="xs:string"/>
    <xsl:variable name="targetDoc"
         select="document($targetUrl, .)"
         as="document-node()?"/>
    <xsl:variable name="resultUrl"
         select="concat($baseOutDir, @href)"
         as="xs:string"/>
    <xsl:variable name="pathTokens"
         select="tokenize($resultUrl, '/')[position() &lt; last()]"/>
    <xsl:variable name="newBase"
          select="concat(string-join($pathTokens, '/'), '/')"
          as="xs:string"/>
    <xsl:result-document href="{$resultUrl}">
      <xsl:apply-templates select="$targetDoc">
        <xsl:with-param name="baseOutDir"
             select="$newBase" tunnel="yes" as="xs:string"/>
      </xsl:apply-templates>
    </xsl:result-document>
    <xsl:copy>
      <xsl:apply-templates select="(@*, node())"/>
    </xsl:copy>
  </xsl:template>

 <xsl:template match="@*">
    <xsl:copy/>
  </xsl:template>

  <xsl:template match="*">
    <xsl:copy>
      <xsl:apply-templates select="(@*, node())"/>
    </xsl:copy>
  </xsl:template>

</xsl:stylesheet>

--
Eliot Kimber
Senior Solutions Architect
"Bringing Strategy, Content, and Technology Together"
Main: 610.631.6770
www.reallysi.com
www.rsuitecms.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>
--~--