xsl-list
[Top] [All Lists]

Re: XPath problem

2004-04-28 15:06:17
At 07:12 AM 4/28/2004, 'twas written:
On Wed, 28 Apr 2004 09:22:18 +0000
"Jonny Pony" <jonnypony666(_at_)hotmail(_dot_)com> 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(_at_)mulberrytech(_dot_)com
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
======================================================================



<Prev in Thread] Current Thread [Next in Thread>