Subject: Re: [xsl] 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 |
Hi All,outputclass="{@type}">
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"
upper-case()}</stentry></sthead>
B B B B B B B B B B B <sthead><stentry>{@type =>
<xsl:otherwise>{$scratch}</xsl:otherwise>
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
select="resolve-uri($doc,base-uri(.))"/>
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="doc($file)//*[@id=$id]"/>
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)/*"/>
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="."/></xsl:otherwise>
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
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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Resolve optional conref and a, rick@xxxxxxxxxxxxxx | Thread | Re: [xsl] Resolve optional conref a, Graydon graydon@xxxx |
[xsl] Resolve optional conref and a, rick@xxxxxxxxxxxxxx | Date | Re: [xsl] Resolve optional conref a, Graydon graydon@xxxx |
Month |