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

RE: Re: Selectively applying Identity transform to mu

Subject: RE: Re: Selectively applying Identity transform to multiple inputs (Multiplexer Style Sheet)
From: cknell@xxxxxxxxxx
Date: Fri, 05 Jan 2007 17:05:56 -0500
RE: Re:  Selectively applying Identity transform to  mu
Instead of using <xsl:copy-of> at the highest level, you can use <xsl:apply-templates />.

In each template you could repeat the <xsl:choose> construct and test for the value of the parameter in question. 

When you wish to copy the element without change (identity transformation), you use the <xsl:copy-of> instruction. When you want to suppress the element altogether, just use a no-output rule.

Example assuming the parameter you wish to evaluate is a global one:

<xsl:template match="some-element-name">
  <xsl:choose>
     <xsl:when test="$parameter-name='no-output'" />
     <xsl:otherwise><xsl:copy-of select="." /></xsl:otherwise>
  </xsl:choose>
</xsl:template>
-- 
Charles Knell
cknell@xxxxxxxxxx - email



-----Original Message-----
From:     Farrukh S. Najmi <farrukh@xxxxxxxxxxxxxxxxxxxxx>
Sent:     Fri, 05 Jan 2007 16:04:14 -0500
To:       xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject:  Re:  Selectively applying Identity transform to multiple inputs (Multiplexer Style Sheet)

cknell@xxxxxxxxxx wrote:
> How about this?
>
>
> <xsl:template match="/">
>   <xsl:choose>
>     <xsl:when test="$input2=''">
>        <xsl:copy-of select="." />
>     </xsl:when>
>     <xsl:otherwise>
>       <xsl:copy-of select="document($input2/)" />
>     </xsl:otherwise>
>   </xsl:choose>
> </xsl:template>
>   
Thanks very much! This does the trick very nicely.

How can I extend above so that I can do selective transformation of some
nodes in the output tree?
For example what if I want to suppress the copying of some nodes based
on a parameter value.

Here is a sample template to selectively copy tp:Comment element. I cant
figure out how how to wire
this to what you suggested earlier.

    <!--
    Only copy tp:Comment if $copyComment is not null
    -->
    <xsl:template match="tp:Comment">       
        <xsl:if test="$copyComment != ''">
            <xsl:copy>
                <xsl:apply-templates select="@*|node()"/>
            </xsl:copy>
        </xsl:if>       
    </xsl:template>   


Thanks again.

-- 
Regards,
Farrukh

Web: http://www.wellfleetsoftware.com

PURCHASE STYLUS STUDIO ONLINE TODAY!

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

Buy Stylus Studio Now

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.