Re: [xsl] apply one template to another

Subject: Re: [xsl] apply one template to another
From: David Carlisle <davidc@xxxxxxxxx>
Date: Wed, 1 Nov 2006 10:29:44 GMT
>  I tried something like this but I couldnt get it to work, 
do you mean it gave an error, or it gave the  wrong answer?
It looks OK, although without seeing an input documemt it's impossible
to say if it matches any element in the input.

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

I'd probably write that as

<xsl:template match="contact" mode="copy">
                <xsl:copy-of select="(/root/contact,.)[1]"/>

(which is probably equivalent, if some assumptions about your input are
correct, if you can have multiple contact children you'd need to change
it slightly.)

But as you have it should work, as long as you do have an element
matching root/xform/xforms:model/xforms:instance/page/contact


Current Thread