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

Re: node-id set <-> result document

Subject: Re: node-id set <-> result document
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Fri, 15 Mar 2002 18:55:48 +0000
set result
Hi Robert,

> I am writing an java app that will resolve general queries over a
> given XML data source. I am using Xalan for the XSLT processing. As
> I need to do postprocessing of the resulting XML doc, I want the XSL
> to return only node ids representing the result doc instead of an
> XML document.
>
> I could image Xalan produce a set of node ids for a given XSLT, send
> it to my app and later after postprocessing I will give back those
> node ids and let Xalan generate a real XML doc out of it.

I think that this approach is going to give you difficulties in terms
of performance. It's very tedious for any program, in particular XSLT,
to identify nodes on the basis of identifiers, especially if there are
a lot of them. I don't know what you're doing precisely, but you might
find it more efficient to have XSLT create a replica of the original
XML document with annotations indicating which nodes need to be
processed, and have that used for post processing and then XSLT
transformation.

Anyway, if you do continue with your current approach, the difficult
is working out an identifier that will be consistent over two runs of
different stylesheets over the same XML document. The generate-id()
function can't help you here, because the ID generated for a
particular node is not guaranteed to be consistent over
transformations.

Instead, you have to create an identifier that you can replicate.
There are lots of ways that you could do it, and which one is best
depends on the structure of your XML document. You could generate
paths to the nodes - for which you need recursive templates or some
processors have an extension function. Or a simple index count.

I'd recommend that you use something that you can write in a single
XPath, so that you can also use it to create a key for the nodes in
the result. For example, to use a simple index count, you could have:

<xsl:key name="nodes" match="node()"
         use="count(preceding::node()|ancestor::node())" />
<xsl:key name="nodes" match="@*"
         use="concat(count(../preceding::node()|../ancestor::node()),
                     '.', name())" />

and then use:

  key('nodes', 142)

to get the 142nd node and:

  key('nodes', '142.type')

to get the type attribute on it.

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/


 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.