Re: [xsl] display parts of XML tree with xsl:copy ?

Subject: Re: [xsl] display parts of XML tree with xsl:copy ?
From: Robert Sösemann <robert.soesemann@xxxxxx>
Date: Thu, 28 Feb 2002 13:43:51 +0100
Thanks a lot Jenni.
But unfortunately I forgat to mention that I need a generic solution.

I cannot include e.g. an extra template for issue because I do not know the
complete supertree.
This XSL should generally work with nearly all kinds of XML docs.
Maybe I forgat also to mention that this is part of an XML Wrapper program
which submit standardized queries to heterogenious XML sources. An attched
source description helps to map to query to xslt, but i definitivly don't
want the uses to note there that the (e.g. issue supertree) must be
traversed and how.

Do you see any possibility to do this generic or at least a bit more generic
;-)

Thanks Robert
----- Original Message -----
From: "Jeni Tennison" <jeni@xxxxxxxxxxxxxxxx>
To: "Robert Sösemann" <robert.soesemann@xxxxxx>
Cc: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
Sent: Tuesday, February 26, 2002 4:43 PM
Subject: Re: [xsl] display parts of XML tree with xsl:copy ?


> Hi Robert,
>
> > How can I controll that only those ancestors are copied that are in
> > an valid articles supertree?
>
> Using the push method (the identity template plus other templates to
> steer the processing), you need to add a template that matches the
> document element of your stylesheet (which I'll assume is called
> 'issues'), and tells the processor to only process those issue
> elements that contain an article with an author named 'Karen Botnich':
>
> <xsl:template match="issues">
>   <issues>
>     <xsl:apply-templates select="issue[articles/article/authors/author =
>                                        'Karen Botnich']" />
>   </issues>
> </xsl:template>
>
> Using the pull method (the single template with the xsl:for-each) you
> do roughly the same thing - just select those issues for processing:
>
> <xsl:template match="/">
>   <issues>
>     <xsl:for-each
>       select="/issues/issue[articles/article/authors/author =
>                             'Karen Botnich']">
>       <issue>
>         <xsl:copy-of select="volume | number" />
>         <articles>
>           <xsl:copy-of
>             select="articles/article[authors/author = 'Karen Botnich']" />
>         </articles>
>       </issue>
>     </xsl:for-each>
>   </issues>
> </xsl:template>
>
> Cheers,
>
> Jeni
>
> ---
> Jeni Tennison
> http://www.jenitennison.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