Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: [xsl] apply one template to another

From: David Carlisle <davidc@--------->
To:
Date: 11/1/2006 10:30:00 AM
>  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


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent