Re: [xsl] Resolve optional conref and apply another template

Subject: Re: [xsl] Resolve optional conref and apply another template
From: "Toshihiko Makita tmakita@xxxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Tue, 18 Jan 2022 00:20:06 -0000
Hi Rick,

 > However, some <note> elements are conrefs to other files. I have this 
template to resolve the conrefs:

It seems that you are using DITA or DITA flavored DocBook introduced in 
below.

DITA for DocBook
https://norman.walsh.name/2005/10/21/dita

Which one are you using? Or are you using proprietary document model 
that supports @conref?

Regards,

On 2022/01/18 7:37, rick@xxxxxxxxxxxxxx wrote:
>
> Hi All,
>
> I have some <note> elements that I want to convert to tables, so I 
> have the following template:
>
> B B B  <!-- Convert caution and warning notes to simpletables. -->
>
> B B B  <xsl:template match="note[@type='caution' or @type='warning']">
>
> B B B B B B B  <simpletable relcolwidth="100*" frame="all" outputclass="{@type}">
>
> <sthead><stentry>{@type => upper-case()}</stentry></sthead>
>
> B B B B B B B B B B B  <strow>
>
> <stentry><xsl:apply-templates/></stentry>
>
> B B B B B B B B B B B  </strow>
>
> B B B B B B B  </simpletable>
>
> B B B  </xsl:template>
>
> However, some <note> elements are conrefs to other files. I have this 
> template to resolve the conrefs:
>
> B B B B <xsl:template match="note[@conref]" priority="2">
>
> B B B B B B B  <xsl:variable name="doc">
>
> B B B B B B B B B B B  <xsl:choose>
>
> B B B B B B B B B B B B B B B  <xsl:when 
> test="contains(@conref,'#')">{substring-before(@conref,'#')}</xsl:when>
>
> B B B B B B B B B <xsl:otherwise>{@conref}</xsl:otherwise>
>
> B B B B B B B B B B B  </xsl:choose>
>
> B B B B B B B  </xsl:variable>
>
> B B B B B B B  <xsl:variable name="id">
>
> B B B B B B B B B B B  <xsl:if test="contains(@conref,'#')">
>
> B B B B B B B B B B B B B B B  <xsl:variable name="scratch" 
> select="substring-after(@conref,'#')"/>
>
> B B B B B B B B B B B B B B B  <xsl:choose>
>
> B B B B B B B B B B B B B B B B B B B  <xsl:when 
> test="contains($scratch,'/')">{tokenize($scratch,'/')[last()]}</xsl:when>
>
> <xsl:otherwise>{$scratch}</xsl:otherwise>
>
> B B B B B B B B B B B B B B B  </xsl:choose>
>
> B B B B B B B B B B B  </xsl:if>
>
> B B B B B B B  </xsl:variable>
>
> B B B B B B B  <xsl:variable name="file" select="resolve-uri($doc,base-uri(.))"/>
>
> B B B B B B B  <xsl:choose>
>
> B B B B B B B B B B B  <xsl:when test="doc-available($file)">
>
> B B B B B B B B B B B B B B B  <xsl:choose>
>
> B B B B B B B B B B B B B B B B B B B  <xsl:when test="($id and $id!='')">
>
> B B B B B B B B B B B B B B B B B B B B B B B  <xsl:copy-of select="doc($file)//*[@id=$id]"/>
>
> B B B B B B B B B B B B B B B B B B B  </xsl:when>
>
> B B B B B B B B B B B B B B B B B B B  <xsl:otherwise>
>
> B B B B B B B B B B B B B B B B B B B B B B B  <xsl:copy-of select="doc($file)/*"/>
>
> B B B B B B B B B B B B B B B B B B B  </xsl:otherwise>
>
> B B B B B B B B B B B B B B B  </xsl:choose>
>
> B B B B B B B B B B B  </xsl:when>
>
> <xsl:otherwise><xsl:copy-of select="."/></xsl:otherwise>
>
> B B B B B B B  </xsl:choose>
>
> B B B  </xsl:template>
>
> I am not sure how to integrate the two templates so that I can convert 
> conref notes to tables too. Any pointers would be appreciated. Thank 
> you very much.
>
> Rick
>
> Rick Quatro
>
> Carmen Publishing Inc.
>
> 585-729-6746
>
> rick@xxxxxxxxxxxxxxx
>
> http://www.frameexpert.com/store
>
> XSL-List info and archive <http://www.mulberrytech.com/xsl/xsl-list>
> EasyUnsubscribe <http://lists.mulberrytech.com/unsub/xsl-list/1528015> 
> (by email <>)

-- 
/*--------------------------------------------------
  Toshihiko Makita
  Development Group. Antenna House, Inc. Ina Branch
  Web site:
  http://www.antenna.co.jp/
  http://www.antennahouse.com/
  --------------------------------------------------*/

Current Thread