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

Re: XPath problem

Subject: Re: XPath problem
From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx>
Date: Wed, 28 Apr 2004 18:06:17 -0400
xpath extract branch
At 07:12 AM 4/28/2004, 'twas written:
On Wed, 28 Apr 2004 09:22:18 +0000
"Jonny Pony" <jonnypony666@xxxxxxxxxxx> wrote:
...
> But I want the tree starting from an other node; e.g. the node <nina>.

then just apply the render templates to a subsection of the document:
...
>             <body>
>                 <h3>Can't find the solution for my problem</h3>
>                 <xsl:apply-templates select="DB/Nina" mode="render"/>
>             </body>

Alternatively, change the template that matches the root (/):

>     <xsl:template match="/" mode="render">
>         tree
>         <br/>
>     <xsl:apply-templates select="DB/Nina" mode="render"/>
>     </xsl:template>

This way you will always start with "tree".

This will work up to a point, but since, for example, the level of indentation is determined by depth of ancestry, and that doesn't change when you process only a subtree, a few more tweaks are called for. Specifically, indentation level can be determined by counting ancestors up to and including the root of the fragment, but not further.


This can be done, although in XSLT 1.0 it's a bit nasty. In most cases it'd be just as easy just to run two passes: one to extract the piece of the tree you wanted to draw, the second to draw it using Jeni's and Mike's stylesheet unchanged.

If it were me, I might use Saxon's next-in-chain feature to call the ASCII-tree-draw stylesheet straight from a branch clipping stylesheet that copied over only the branch I wanted. That'd be easy, fast, and have no need for fancy XPath. There are also other ways to chain stylesheets together.

Cheers,
Wendell


====================================================================== Wendell Piez mailto:wapiez@xxxxxxxxxxxxxxxx Mulberry Technologies, Inc. http://www.mulberrytech.com 17 West Jefferson Street Direct Phone: 301/315-9635 Suite 207 Phone: 301/315-9631 Rockville, MD 20850 Fax: 301/315-8285 ---------------------------------------------------------------------- Mulberry Technologies: A Consultancy Specializing in SGML and XML ======================================================================

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.