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

Re: <xsl:copy-of> question

Subject: Re: <xsl:copy-of> question
From: "Nikolai Grigoriev" <grig@xxxxxxx>
Date: Thu, 16 Dec 1999 04:36:56 +0300
xsl copy of extension
My solution is 4 lines in 2 templates (not counting the comments):

<!-- By default, copy a node with all the children through. -->
<!-- Attributes are dropped; to include them, use match="*|@*" -->

<xsl:template match="*">
  <xsl:copy> <xsl:apply-templates/> </xsl:copy>
</xsl:template>

<!-- Processing of salary nodes is disabled for FullSecurity="0" -->
<xsl:template match="salary[/employee/@FullSecurity=0]"/>

Tested on XT, and did work.

Regards,
Nikolai

-----Original Message-----
From: Hunter, David <dhunter@xxxxxxxxxxxx>
To: 'XSL-list' <xsl-list@xxxxxxxxxxxxxxxx>
Date: Thursday, December 16, 1999 1:36 AM
Subject: <xsl:copy-of> question


>Suppose I have the following XML:
>
><employee FullSecurity="0">
>  <name>John Doe</name>
>  <department>Widget Sales</department>
>  <phone>(555)555-5555<extension>2974</extension></phone>
>  <salary>62,000</salary>
>  <area>3</area>
></employee>
>
>I want to create a very simple XSL stylesheet which does the following:  If
>the FullSecurity attribute evaluates to "true", then copy all of the source
>tree to the result tree.  If the FullSecurity attribute evaluates to
>"false", copy all of the source tree *except for the <salary> element* to
>the result tree.  The closest I can get is something like the following:
>
><xsl:stylesheet version="1.0"
>xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
><xsl:template match="/">
>  <xsl:choose>
>    <xsl:when test="number(/employee/@FullSecurity)"><xsl:copy-of
>select="/"/></xsl:when>
>    <xsl:otherwise>
>      <employee>
>        <xsl:copy-of select="//name | //department | //phone | //area"/>
>      </employee>
>    </xsl:otherwise>
>  </xsl:choose>
></xsl:template>
></xsl:stylesheet>
>
>Is there a more succinct way of saying "copy all of the <employee> element
>to the result tree *except* for the <salary> element"?
>
>If it matters, I'm using the Win32 executable version of XT, but I want
>something that's totally generic, so I'd rather not use extension
functions.
>
>David Hunter
>MobileQ
>david.hunter@xxxxxxxxxxx
>http://www.MobileQ.com
>
>
> XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
>



 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

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