Next in thread → Next in month →

Re: DOCBOOK-APPS: ulink and HTML target

From
Michael Wiedmann <>
Date
2002-08-09T18:40:49+00:00
ID
Thread
Re: DOCBOOK-APPS: ulink and HTML target
* Bob Stayton <> [020809 10:33]:

> Nothing built in to do this.
> I think you would have to do a customization of
> the ulink template to respond to a target value in the
> role attribute in ulinks.

To share my solution with others, this is what I've done:

  <!-- override ulink template (from xref.xsl):
       generate HTML attribute target="_blank" if role attribute
       of ulink is equal to "newwindow"
  -->
  <xsl:template match="ulink" name="ulink">
    <xsl:variable name="link">
      <a>
        <xsl:if test="@id">
          <xsl:attribute name="name">
            <xsl:value-of select="@id"/>
          </xsl:attribute>
        </xsl:if>
        <xsl:attribute name="href"><xsl:value-of select="@url"/></xsl:attribute>
        <!-- Begin Change by MW -->
        <xsl:if test="@role = 'newwindow'">
          <xsl:attribute name="target">
            <xsl:text>_blank</xsl:text>
          </xsl:attribute>
        </xsl:if>
        <!-- End Change -->

        <xsl:choose>
          <xsl:when test="count(child::node())=0">
            <xsl:value-of select="@url"/>
          </xsl:when>
          <xsl:otherwise>
            <xsl:apply-templates/>
          </xsl:otherwise>
        </xsl:choose>
      </a>
    </xsl:variable>

    <xsl:copy-of select="$link"/>
  </xsl:template>

Michael
-- 
                              http://www.miwie.org
Next in thread → Next in month →