Skip to content

Commit

Permalink
Fixes #34 Corrected generation of relative paths, main index.html pag…
Browse files Browse the repository at this point in the history
…e works
  • Loading branch information
contrext committed Mar 19, 2015
1 parent 65e913c commit 8f2b669
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 12 deletions.
20 changes: 17 additions & 3 deletions xsl/map2html5Nav.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,15 @@
exclude-result-prefixes="local xs df xsl relpath htmlutil index-terms mapdriven glossdata enum">

<xsl:template name="navigation">
<xsl:param name="doDebug" as="xs:boolean" tunnel="yes" select="$debugBoolean"/>
<xsl:param name="navigation" as="element()*" tunnel="yes" />
<xsl:param name="is-root" as="xs:boolean" tunnel="yes" select="false()" />
<xsl:param name="resultUri" as="xs:string" tunnel="yes" select="''" />

<xsl:if test="$doDebug">
<xsl:message> + [DEBUG] navigation: resultUri="<xsl:value-of select="$resultUri"/></xsl:message>
</xsl:if>

<xsl:if test="$OUTPUTDEFAULTNAVIGATION and $is-root = false()">
<xsl:variable name="navigation-fixed">
<xsl:apply-templates select="$navigation" mode="fix-navigation-href">
Expand Down Expand Up @@ -274,6 +279,7 @@
</xsl:template>

<xsl:template match="li" mode="fix-navigation-href">
<xsl:param name="doDebug" as="xs:boolean" tunnel="yes" select="$debugBoolean"/>
<xsl:param name="resultUri" as="xs:string" tunnel="yes" select="''" /><!-- Result URI of the topic we're processing -->

<xsl:variable name="href" as="xs:string" select="a/@href"/>
Expand All @@ -292,14 +298,22 @@
source: the directory we are starting *from*
target: the directory we are going *to*
-->
-->
<xsl:variable name="relPathToDir" as="xs:string"
select="relpath:getRelativePath(relpath:getParent($targetResourcePart), relpath:getParent($resultUri))"
select="relpath:getRelativePath(relpath:getParent($resultUri), relpath:getParent($targetResourcePart))"
/>
<xsl:variable name="relPath" as="xs:string"
select="concat($relPathToDir, relpath:getName($targetResourcePart))"
select="relpath:newFile($relPathToDir, relpath:getName($targetResourcePart))"
/>
<xsl:variable name="targetRelativeUri" as="xs:string" select="concat($relPath, $fragmentID)"/>
<xsl:if test="$doDebug">
<xsl:message> + [DEBUG] fix-navigation-href: source path="<xsl:value-of
select="relpath:getParent($resultUri)"/>"</xsl:message>
<xsl:message> + [DEBUG] fix-navigation-href: target path="<xsl:value-of
select="relpath:getParent($targetResourcePart)"/>"</xsl:message>
<xsl:message> + [DEBUG] fix-navigation-href: relPathToDir="<xsl:value-of select="$relPathToDir"/>"</xsl:message>
<xsl:message> + [DEBUG] fix-navigation-href: relPath="<xsl:value-of select="$relPath"/>"</xsl:message>
</xsl:if>

<xsl:variable name="isActiveTrail" select="descendant::*[ends-with(@href, $targetRelativeUri)]"/>
<xsl:variable name="hasChild" select="descendant::li"/>
Expand Down
12 changes: 4 additions & 8 deletions xsl/map2html5RootContent.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,6 @@
select="string(@href)"/>"</xsl:message>
</xsl:when>
<xsl:otherwise>
<xsl:variable name="topicRelativeUri" select="htmlutil:getTopicResultUrl('', root($topic), $rootMapDocUrl)"
as="xs:string"/>

<xsl:variable name="tempTopic" as="document-node()">
<xsl:document>
<xsl:apply-templates select="$topic" mode="href-fixup">
Expand All @@ -78,7 +75,6 @@
<xsl:apply-templates select="$tempTopic" mode="#current">
<xsl:with-param name="topicref" as="element()*" select="." tunnel="yes"/>
<xsl:with-param name="collected-data" select="$collected-data" as="element()" tunnel="yes"/>
<xsl:with-param name="topicRelativeUri" select="$topicRelativeUri" tunnel="yes"/>
</xsl:apply-templates>


Expand All @@ -95,14 +91,14 @@
<!-- Enumerables structure: -->
<xsl:param name="collected-data" as="element()" tunnel="yes"/>

<xsl:variable name="resultUri" as="xs:string" select="relpath:newFile($outdir, $indexUri)"/>

<xsl:message> + [INFO] Writing first topic to HTML file "<xsl:sequence select="$indexUri"/>"...</xsl:message>
<xsl:message> + [INFO] Writing first topic to HTML file "<xsl:sequence select="$resultUri"/>"...</xsl:message>

<xsl:result-document format="html5" href="{$indexUri}">
<xsl:apply-templates mode="generate-html5-page" select=".">
<xsl:with-param name="resultUri" as="xs:string" select="$indexUri" tunnel="yes"/>
<xsl:with-param name="resultUri" as="xs:string" select="$resultUri" tunnel="yes"/>
<xsl:with-param name="is-root" as="xs:boolean" select="false()" tunnel="yes"/>
<xsl:with-param name="relativePath" select="''" as="xs:string" tunnel="yes"/>
</xsl:apply-templates>
</xsl:result-document>

Expand All @@ -129,10 +125,10 @@
else htmlutil:getInitialTopicrefUri($uniqueTopicRefs, $topicsOutputPath, $outdir, $rootMapDocUrl)
"
/>

<xsl:message> + [INFO] Generating root index HTML document <xsl:sequence select="$indexUri"/>...</xsl:message>
<xsl:result-document format="{$xsloutput}" href="{$indexUri}">
<xsl:apply-templates mode="generate-html5-page" select=".">
<xsl:with-param name="doDebug" as="xs:boolean" tunnel="yes" select="$debugBoolean"/>
<xsl:with-param name="resultUri" as="xs:string" select="$indexUri" tunnel="yes"/>
<xsl:with-param name="is-root" as="xs:boolean" select="true()" tunnel="yes"/>
<xsl:with-param name="firstTopicUri" as="xs:string?" tunnel="yes" select="$initialTopicUri" />
Expand Down
4 changes: 3 additions & 1 deletion xsl/map2html5Template.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,9 @@
<xsl:param name="resultUri" as="xs:string" tunnel="yes" select="''" />

<div id="{$IDSECTIONCONTAINER}" class="{$CLASSSECTIONCONTAINER}">
<xsl:call-template name="navigation"/>
<xsl:call-template name="navigation">
<xsl:with-param name="doDebug" as="xs:boolean" tunnel="yes" select="$debugBoolean"/>
</xsl:call-template>
<xsl:apply-templates select="." mode="generate-main-content"/>
<div class="clearfix"></div>
</div>
Expand Down

0 comments on commit 8f2b669

Please sign in to comment.