[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: apply one template to another

Subject: Re: apply one template to another
From: David Carlisle <davidc@xxxxxxxxx>
Date: Wed, 1 Nov 2006 10:29:44 GMT
Re:  apply one template to another
>  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:template
match="/root/xform/xforms:model/xforms:instance/page/contact"
mode="copy">
        <xsl:choose>
            <xsl:when test="empty(/root/contact)">
                <xsl:copy-of select="."/>
            </xsl:when>   
            <xsl:otherwise>
                <xsl:copy-of select="/root/contact"/>
            </xsl:otherwise>
        </xsl:choose>
</xsl:template>



I'd probably write that as

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

(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

David

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Cast Your Vote

We need your help – Vote for DataDirect XML Products!

  • Best SOA or XML site

Winners and finalists announced at SOA World Conference in November.

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-2007 All Rights Reserved.