| 1 | <?xml version="1.0"?> |
|---|
| 2 | <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" |
|---|
| 3 | xmlns:suwl="http://nwalsh.com/xslt/ext/com.nwalsh.saxon.UnwrapLinks" |
|---|
| 4 | exclude-result-prefixes="suwl" |
|---|
| 5 | version="1.0"> |
|---|
| 6 | |
|---|
| 7 | <!-- Import the HTML chunking stylesheet --> |
|---|
| 8 | <xsl:import |
|---|
| 9 | href="http://docbook.sourceforge.net/release/xsl/current/html/xref.xsl"/> |
|---|
| 10 | |
|---|
| 11 | |
|---|
| 12 | <xsl:template name="adjust-url"> |
|---|
| 13 | <xsl:param name="target"/> |
|---|
| 14 | <xsl:param name="context" select="."/> |
|---|
| 15 | |
|---|
| 16 | <xsl:choose> |
|---|
| 17 | <xsl:when test="contains($target, ':')"> |
|---|
| 18 | <xsl:value-of select="$target"/> |
|---|
| 19 | </xsl:when> |
|---|
| 20 | <xsl:otherwise> |
|---|
| 21 | <xsl:call-template name="href.target.relative"> |
|---|
| 22 | <xsl:with-param name="target" select="$target"/> |
|---|
| 23 | </xsl:call-template> |
|---|
| 24 | </xsl:otherwise> |
|---|
| 25 | </xsl:choose> |
|---|
| 26 | |
|---|
| 27 | </xsl:template> |
|---|
| 28 | |
|---|
| 29 | |
|---|
| 30 | <xsl:template match="ulink" name="ulink"> |
|---|
| 31 | <xsl:variable name="link"> |
|---|
| 32 | <a> |
|---|
| 33 | <xsl:if test="@id"> |
|---|
| 34 | <xsl:attribute name="name"> |
|---|
| 35 | <xsl:value-of select="@id"/> |
|---|
| 36 | </xsl:attribute> |
|---|
| 37 | </xsl:if> |
|---|
| 38 | <xsl:attribute name="href"> |
|---|
| 39 | <xsl:call-template name="adjust-url"> |
|---|
| 40 | <xsl:with-param name="target" select="@url"/> |
|---|
| 41 | </xsl:call-template> |
|---|
| 42 | </xsl:attribute> |
|---|
| 43 | <xsl:if test="$ulink.target != ''"> |
|---|
| 44 | <xsl:attribute name="target"> |
|---|
| 45 | <xsl:value-of select="$ulink.target"/> |
|---|
| 46 | </xsl:attribute> |
|---|
| 47 | </xsl:if> |
|---|
| 48 | <xsl:choose> |
|---|
| 49 | <xsl:when test="count(child::node())=0"> |
|---|
| 50 | <xsl:value-of select="@url"/> |
|---|
| 51 | </xsl:when> |
|---|
| 52 | <xsl:otherwise> |
|---|
| 53 | <xsl:apply-templates/> |
|---|
| 54 | </xsl:otherwise> |
|---|
| 55 | </xsl:choose> |
|---|
| 56 | </a> |
|---|
| 57 | </xsl:variable> |
|---|
| 58 | |
|---|
| 59 | <xsl:choose> |
|---|
| 60 | <xsl:when test="function-available('suwl:unwrapLinks')"> |
|---|
| 61 | <xsl:copy-of select="suwl:unwrapLinks($link)"/> |
|---|
| 62 | </xsl:when> |
|---|
| 63 | <xsl:otherwise> |
|---|
| 64 | <xsl:copy-of select="$link"/> |
|---|
| 65 | </xsl:otherwise> |
|---|
| 66 | </xsl:choose> |
|---|
| 67 | </xsl:template> |
|---|
| 68 | |
|---|
| 69 | |
|---|
| 70 | </xsl:stylesheet> |
|---|