[xsl] apply one template to another

Subject: [xsl] apply one template to another
From: "Adam Retter" <adam.retter@xxxxxxxxxxxx>
Date: Wed, 1 Nov 2006 10:19:20 -0000
I am using a copy pattern that Michael Kay very kindly described
originally for me.
These are the last two templates in my document that do the copying-

<xsl:template match="*" mode="copy">
            <xsl:copy-of select="@*"/>
            <xsl:apply-templates mode="copy"/>
<xsl:template match="/root/xform">
        <xsl:apply-templates mode="copy"/>

Now I have a template that makes a conditional copy of the
/root/xform/xforms:model/xforms:instance node -

    <xsl:template match="/root/xform/xforms:model/xforms:instance"
            <xsl:copy-of select="@*"/>
                <xsl:when test="empty(/root/page)">
                    <xsl:copy-of select="child::node()"/>
                    <xsl:copy-of select="/root/page"/>

Now, what I would like to do is apply a template to that template, so
that I can conditionally replace the
/root/xform/xforms:model/xforms:instance/page/contact node with a custom
node. I tried something like this but I couldnt get it to work, I also
tried playing with priorities and modes but didnt make any progress.

            <xsl:when test="empty(/root/contact)">
                <xsl:copy-of select="."/>
                <xsl:copy-of select="/root/contact"/>

If you could provide me with details of how to acheive that, I think I
could extend that to other nodes that I want to conditinally replace
with custom nodes -


Thanks very much - Adam Retter

For reference my XML document structure looks something like this -

            <number type="Office">01404 812345</number>
        <address>The Old Institute</address>
        <address>Yonder Street</address>
        <town>Ottery St Mary</town>
        <postcode>EX11 1XX</postcode>
    <xform xmlns:xlink="http://www.w3.org/1999/xlink";
xmlns:ev="http://www.w3.org/2001/xml-events"; xmlns:xforms
        <xforms:model ev:event="xforms-revalidate"
            <xforms:submission id="submit"
xql?action=savepage" method="post" replace="all"/>
                <page design="event">

Adam Retter

Principal Developer
Devon Portal Project, e-Partnership
Ext: 3683
DDI: 01392 383683
e: adam.retter@xxxxxxxxxxxx


Current Thread