← Prev in month ← Prev in thread

Can't select link if 'linkend' contains text

From
Xmplar <>
Date
2011-12-23T11:34:35+00:00
ID
Thread
Can't select link if 'linkend' contains text
I have in a document, d:link - for both links to other text in the
    document (e.g. link to a figure) as well as links to URLs. For both
    types of links I am using d:link. I would like the following code to
    select only those instances where the @linkend contains the string
    'http' - and to then put angle brackets before and after those URLs.
    The if:test syntax under variable "content" is obviously wrong -
    what is the correct syntax for selecting linkends that are only
    URLs?

    Thanks

    

    <xsl:template match="d:link" name="link">

        <xsl:param name="linkend" select="@linkend"/>

        <xsl:param name="targets" select="key('id',$linkend)"/>

        <xsl:param name="target" select="$targets[1]"/>

        

        <xsl:variable name="xrefstyle">

          <xsl:choose>

            <xsl:when test="@role and not(@xrefstyle) 

              and $use.role.as.xrefstyle != 0">

              <xsl:value-of select="@role"/>

            </xsl:when>

            <xsl:otherwise>

              <xsl:value-of select="@xrefstyle"/>

            </xsl:otherwise>

          </xsl:choose>

        </xsl:variable>

        

        <xsl:variable name="content">

          <xsl:if test="contains(linkend,'http')">

          <xsl:value-of select="$puncbeforeurl"/>

          </xsl:if>

          <!--<xsl:if test="ancestor::d:bibliomixed or
    ancestor::d:bibliography">

            <xsl:value-of select="$puncbeforeurl"/>

          </xsl:if>-->

          <fo:inline xsl:use-attribute-sets="xref.properties">

            <xsl:choose>

              <xsl:when test="count(child::node()) &gt; 0">

                <!-- If it has content, use it -->

                <xsl:apply-templates/>

              </xsl:when>

              <!-- look for an endterm -->

              <xsl:when test="@endterm">

                <xsl:variable name="etargets"
    select="key('id',@endterm)"/>

                <xsl:variable name="etarget"
    select="$etargets[1]"/>

                <xsl:choose>

                  <xsl:when test="count($etarget) = 0">

                    <xsl:message>

                      <xsl:value-of select="count($etargets)"/>

                      <xsl:text>Endterm points to nonexistent ID:
    </xsl:text>

                      <xsl:value-of select="@endterm"/>

                    </xsl:message>

                    <xsl:text>???</xsl:text>

                  </xsl:when>

                  <xsl:otherwise>

                    <xsl:apply-templates select="$etarget"
    mode="endterm"/>

                  </xsl:otherwise>

                </xsl:choose>

              </xsl:when>

              <!-- Use the xlink:href if no other text -->

              <xsl:when test="@xlink:href">

                <xsl:call-template name="hyphenate-url">

                  <xsl:with-param name="url"
    select="@xlink:href"/>

                </xsl:call-template>

              </xsl:when>

              <xsl:otherwise>

                <xsl:message>

                  <xsl:text>Link element has no content and no
    Endterm. </xsl:text>

                  <xsl:text>Nothing to show in the link to
    </xsl:text>

                  <xsl:value-of select="$target"/>

                </xsl:message>

                <xsl:text>???</xsl:text>

              </xsl:otherwise>

            </xsl:choose>

          </fo:inline>

          <xsl:if test="contains(linkend,'http')">

            <xsl:value-of select="$puncafterurl"/>

          </xsl:if>

          

    

    
-- 

      Dave Gardiner
← Prev in month ← Prev in thread