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

display parts of XML tree with xsl:copy ?

Subject: [xsl] display parts of XML tree with xsl:copy ?
From: Robert Sösemann <robert.soesemann@xxxxxx>
Date: Tue, 26 Feb 2002 00:05:08 +0100
parts of a tree
How can I solve the following problem?

>From the following article DB (SigmodRecord) i want to e.g. only articles by
a certain author
but the result tree should still contain the information of <number> which
is nearer to the root.

Below you also find my test query.

######################### SAMPLE XML
###############################################

<issue>
 <volume>11</volume>
 <number>1</number>
 <articles>
  <article>
   <title>Annotated Bibliography on Data Design.</title>
   <initPage>45</initPage>
   <endPage>77</endPage>
   <authors>
    <author position="00">Anthony I. Wasserman</author>
    <author position="01">Karen Botnich</author>
   </authors>
  </article>

  <article>
   <title>Architecture of Future Data Base Systems.</title>
   <initPage>30</initPage>
   <endPage>44</endPage>
   <authors>
    <author position="00">Lawrence A. Rowe</author>
    <author position="01">Michael Stonebraker</author>
   </authors>
  </article>
  <!-- a lot more articles //-->
 </articles>
  </issue>
  <issue>
   <volume>11</volume>
   <number>2</number>
   <articles>

  <!-- a lot more articles //-->

################### MY XSLT - QUERY
##########################################

<?xml version="1.0"?>
<xsl:transform version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml"/>

 <xsl:template match="/child::*">
   <xsl:copy>
     <xsl:for-each select="//article">
    <xsl:choose>
   <xsl:when test=".//author='Karen Botnich'">
     <xsl:copy-of select="."/>
   </xsl:when>

   <xsl:otherwise/>
    </xsl:choose>
  </xsl:for-each>
   </xsl:copy>
 </xsl:template>

</xsl:transform>

If I use <xsl:copy-of select=".."/> instead of <xsl:copy-of select="."/> I
get even those <articles> that
don't fullfil my query, but I only want the issue-number.


 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.