At 2006-09-05 12:55 +0000, Neville Lugton wrote:
Simplified.. I am trying to use
"xsl:call-template" from an included .xsl file
to insert a named template stored in the main .xsl file.
However not all the main files are going to
need/have the named template. So I only want to
use "xsl:call-template" if the target document has the required named template.
So far I'm working on the theory I need something like the code below:
There are a number of issues in the code that need to be addressed.
<xsl:template match="/">
<xsl:call-template name="insertHeader"/>
</xsl:template>
<xsl:template match="insertHeader">
I'm guessing you want name="insertHeader" above.
<!-- this template is included in ALL files -->
<xsl:if test="element-available(pageScripts)">
The element-available() function is only used to
test the presence of an instruction (built-in or
extension, and without a namespace (as you have
it) it would have to be built-in, and
<pageScripts> is not an instruction in XSLT). If
all you want to do is check if the document
element is <pageScripts> then you need to do:
<xsl:if test="pageScripts">
If it isn't the document element then you will
need to address where the element is in order to test its presence.
<xsl:call-template name="insertScripts"/>
</xsl:if>
</xsl:template>
<xsl:template name="insertScripts">
<!-- NOT all files have this template -->
do things!!
</xsl:template>
Can anyone help me with what test I need for
"<xsl:if test="??????">" or suggest another way to go about it all.
You need to fragment your stylesheet and use
<xsl:import> and the import hierarchy (which is
different than the include hierarchy).
If all of your stylesheets imported a very short
stylesheet with your default behaviour for the
template named "insertScripts", then those
stylesheets that included such a template would
override your default template, while those
stylesheets that don't include such a template
would engage your default template.
Then, no test is needed ... you just always
engage the template by name and if you want
nothing to happen by default than your default template is empty.
I hope this helps.
. . . . . . . . . . . . Ken
--
UBL/XML/XSLT/XSL-FO training: Vårø, Denmark 2006-10-02/06,11-20/24
UBL International 2006 2006-11-13/17 http://www.ublconference.com
World-wide corporate, govt. & user group UBL, XSL, & XML training.
G. Ken Holman mailto:gkholman(_at_)CraneSoftwrights(_dot_)com
Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/
Box 266, Kars, Ontario CANADA K0A-2E0 +1(613)489-0999 (F:-0995)
Male Cancer Awareness Aug'05 http://www.CraneSoftwrights.com/s/bc
Legal business disclaimers: http://www.CraneSoftwrights.com/legal
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--