| 1 | <?xml version="1.0"?> |
|---|
| 2 | <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" |
|---|
| 3 | version="1.0"> |
|---|
| 4 | |
|---|
| 5 | <xsl:import href="http://docbook.sourceforge.net/release/xsl/current/lib/lib.xsl"/> |
|---|
| 6 | |
|---|
| 7 | <!-- ==================================================================== --> |
|---|
| 8 | |
|---|
| 9 | <xsl:template name="href.target.relative"> |
|---|
| 10 | <xsl:param name="target"/> |
|---|
| 11 | <xsl:param name="context" select="."/> |
|---|
| 12 | |
|---|
| 13 | <xsl:variable name="href.to.uri" select="$target"/> |
|---|
| 14 | <xsl:variable name="href.from.uri"> |
|---|
| 15 | <xsl:call-template name="href.target.uri"> |
|---|
| 16 | <xsl:with-param name="object" select="$context"/> |
|---|
| 17 | </xsl:call-template> |
|---|
| 18 | </xsl:variable> |
|---|
| 19 | |
|---|
| 20 | <xsl:variable name="href.to"> |
|---|
| 21 | <xsl:call-template name="trim.common.uri.paths"> |
|---|
| 22 | <xsl:with-param name="uriA" select="$href.to.uri"/> |
|---|
| 23 | <xsl:with-param name="uriB" select="$href.from.uri"/> |
|---|
| 24 | <xsl:with-param name="return" select="'A'"/> |
|---|
| 25 | </xsl:call-template> |
|---|
| 26 | </xsl:variable> |
|---|
| 27 | |
|---|
| 28 | <xsl:variable name="href.from"> |
|---|
| 29 | <xsl:call-template name="trim.common.uri.paths"> |
|---|
| 30 | <xsl:with-param name="uriA" select="$href.to.uri"/> |
|---|
| 31 | <xsl:with-param name="uriB" select="$href.from.uri"/> |
|---|
| 32 | <xsl:with-param name="return" select="'B'"/> |
|---|
| 33 | </xsl:call-template> |
|---|
| 34 | </xsl:variable> |
|---|
| 35 | |
|---|
| 36 | <xsl:variable name="depth"> |
|---|
| 37 | <xsl:call-template name="count.uri.path.depth"> |
|---|
| 38 | <xsl:with-param name="filename" select="$href.from"/> |
|---|
| 39 | </xsl:call-template> |
|---|
| 40 | </xsl:variable> |
|---|
| 41 | |
|---|
| 42 | <xsl:variable name="href"> |
|---|
| 43 | <xsl:call-template name="copy-string"> |
|---|
| 44 | <xsl:with-param name="string" select="'../'"/> |
|---|
| 45 | <xsl:with-param name="count" select="$depth"/> |
|---|
| 46 | </xsl:call-template> |
|---|
| 47 | <xsl:value-of select="$href.to"/> |
|---|
| 48 | </xsl:variable> |
|---|
| 49 | |
|---|
| 50 | <xsl:value-of select="$href"/> |
|---|
| 51 | |
|---|
| 52 | </xsl:template> |
|---|
| 53 | |
|---|
| 54 | </xsl:stylesheet> |
|---|