[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
[Recent Entries]
[Reply To This Message]
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.
|
PURCHASE STYLUS STUDIO ONLINE TODAY!
Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!
Download The World's Best XML IDE!
Accelerate XML development with our award-winning XML IDE - Download a free trial today!
Subscribe in XML format
RSS 2.0 |
|
Atom 0.3 |
|
|