[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Resolve optional conref and apply another template

Subject: Re: Resolve optional conref and apply another template
From: "Martin Honnen martin.honnen@xxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Mon, 17 Jan 2022 22:45:55 -0000
Re:  Resolve optional conref and apply another template
On 17.01.2022 23:36, 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}">

B B B B B B B B B B B <sthead><stentry>{@type =>
upper-case()}</stentry></sthead>

B B B B B B B B B B B <strow>


B B B B B B B B B B B B B B B <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 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>

B B B B B B B B B B B B B B B B B B B
<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>

B B B B B B B B B B B <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.

So what kind of element(s) does doc($file)//*[@id=$id] in <xsl:copy-of select="doc($file)//*[@id=$id]"/> select? "note" elements that need to be converted?

If you want to apply your template you would need
  <xsl:apply-templates select="doc($file)//*[@id=$id]"/>
it seems.

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.