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

RE: select only some elements and attributes

Subject: RE: select only some elements and attributes
From: "Evan Lenz" <elenz@xxxxxxxxxxx>
Date: Wed, 14 Feb 2001 17:42:16 -0800
xslt only some elements
Try this:

<xsl:stylesheet version="1.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

  <xsl:template match="title | price | weight | company | phone | @*">
    <xsl:copy-of select="."/> <!--performs a "deep" copy" -->
  </xsl:template>

  <xsl:template match="product | vendor">
    <xsl:copy>  <!-- performs a "shallow" copy -->
      <xsl:apply-templates select="* | @*"/>
    </xsl:copy>
  </xsl:template>

  <xsl:template match="*"/>
  <!-- for all other elements, do nothing (this overrides the built-in
template rule for elements) -->

</xsl:stylesheet>

Hope this helps,

Evan Lenz
XYZFind Corp.

-----Original Message-----
From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx
[mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx]On Behalf Of Meili Zhong
Sent: Wednesday, February 14, 2001 4:55 PM
To: XSL-List@xxxxxxxxxxxxxxxxxxxxxx
Subject:  select only some elements and attributes


Hi, What's the best way to only select some elements and attributes using
xslt? For example, the xml source looks like:

<product sku="123465-45">
   <title>Mutton and Rice Dog Food</title>
   <description sku="2345-67">Everything needed for your pet's
health</description>
   <price>25.99</price>
   <available_date>2000-12-25</available_date>
   <size>large</size>
   <weight>40lbs</weight>
   <vendor>
      <company>Nutro Max</company>
      <street>15 Industrial Blvd</street>
      <city>Reno</city>
      <state>NV</state>
      <zip>56381</zip>
      <phone>583 233-4598</phone>
   </vendor>
</product>

The output I want should be like:

<product sku="123465-45">
   <title>Mutton and Rice Dog Food</title>
   <price>25.99</price>
   <weight>40lbs</weight>
   <vendor>
      <company>Nutro Max</company>
      <phone>583 233-4598</phone>
   </vendor>
</product>

Thank you very much!

Meili Zhong


 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.