This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
display parts of XML tree with xsl:copy ?
- From: Robert Sösemann <robert dot soesemann at web dot de>
- To: <XSL-List at lists dot mulberrytech dot com>
- Date: Tue, 26 Feb 2002 00:05:08 +0100
- Subject: [xsl] display parts of XML tree with xsl:copy ?
- Reply-to: xsl-list at lists dot mulberrytech dot com
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