[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: "Chris Papademetrious christopher.papademetrious@xxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Mon, 17 Jan 2022 22:51:44 -0000
Re:  Resolve optional conref and apply another template
Hi Rick,

To combine templates, I typically use <xsl:next-match> to apply whatever the
next-in-line template would have been. I put the results in a variable, then
process the contents of the variable:

    <!-- Convert caution and warning notes to simpletables. -->
    <xsl:template match="note[@type='caution' or @type='warning']"
priority="10">
        <xsl:variable name="results">
            <xsl:next-match/>  <!-- apply other templates first, just in case
-->
        </xsl:variable>
        <simpletable relcolwidth="100*" frame="all" outputclass="{@type}">
            <sthead><stentry>{@type => upper-case()}</stentry></sthead>
            <strow>
                <stentry><xsl:sequence select="$results/node()"/></stentry>
            </strow>
        </simpletable>
    </xsl:template>

If you use this approach, you'll want your caution/warning template to have
the higher priority (so it calls your @conref template as the next-in-line
template).


  *   Chris


From: rick@xxxxxxxxxxxxxx <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Sent: Monday, January 17, 2022 5:37 PM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject:  Resolve optional conref and apply another template

Hi All,

I have some <note> elements that I want to convert to tables, so I have the
following template:

    <!-- Convert caution and warning notes to simpletables. -->
    <xsl:template match="note[@type='caution' or @type='warning']">
        <simpletable relcolwidth="100*" frame="all" outputclass="{@type}">
            <sthead><stentry>{@type => upper-case()}</stentry></sthead>
            <strow>
                <stentry><xsl:apply-templates/></stentry>
            </strow>
        </simpletable>
    </xsl:template>

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

    <xsl:template match="note[@conref]" priority="2">
        <xsl:variable name="doc">
            <xsl:choose>
                <xsl:when
test="contains(@conref,'#')">{substring-before(@conref,'#')}</xsl:when>
                <xsl:otherwise>{@conref}</xsl:otherwise>
            </xsl:choose>
        </xsl:variable>
        <xsl:variable name="id">
            <xsl:if test="contains(@conref,'#')">
                <xsl:variable name="scratch"
select="substring-after(@conref,'#')"/>
                <xsl:choose>
                    <xsl:when
test="contains($scratch,'/')">{tokenize($scratch,'/')[last()]}</xsl:when>
                    <xsl:otherwise>{$scratch}</xsl:otherwise>
                </xsl:choose>
            </xsl:if>
        </xsl:variable>
        <xsl:variable name="file" select="resolve-uri($doc,base-uri(.))"/>
        <xsl:choose>
            <xsl:when test="doc-available($file)">
                <xsl:choose>
                    <xsl:when test="($id and $id!='')">
                        <xsl:copy-of select="doc($file)//*[@id=$id]"/>
                    </xsl:when>
                    <xsl:otherwise>
                        <xsl:copy-of select="doc($file)/*"/>
                    </xsl:otherwise>
                </xsl:choose>
            </xsl:when>
            <xsl:otherwise><xsl:copy-of select="."/></xsl:otherwise>
        </xsl:choose>
    </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<mailto:rick@xxxxxxxxxxxxxxx>
http://www.frameexpert.com/store<https://urldefense.com/v3/__http:/www.framee
xpert.com/store__;!!A4F2R9G_pg!PAl4W0RGU2mzM5zkhGiCgLd8JgviiODhv_Kkz7PeGcKhN0
OzaU0noYnp5IAZ0NfnpjO93T0BGmaYXHE$>



XSL-List info and
archive<https://urldefense.com/v3/__http:/www.mulberrytech.com/xsl/xsl-list__
;!!A4F2R9G_pg!PAl4W0RGU2mzM5zkhGiCgLd8JgviiODhv_Kkz7PeGcKhN0OzaU0noYnp5IAZ0Nf
npjO93T0B7s5x5Nc$>
EasyUnsubscribe<https://urldefense.com/v3/__http:/lists.mulberrytech.com/unsu
b/xsl-list/3380743__;!!A4F2R9G_pg!PAl4W0RGU2mzM5zkhGiCgLd8JgviiODhv_Kkz7PeGcK
hN0OzaU0noYnp5IAZ0NfnpjO93T0BUffucSQ$> (by email<>)

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.