[Home] [By Thread] [By Date] [Recent Entries]
Andrew Welch wrote:
On 06/03/2008, Eliot Kimber <ekimber@xxxxxxxxxxxx> wrote:Can someone tell me what stupid thing I'm doing? 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[@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() < 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
|

Cart



