Thank you, Dave.
Yes, I probably mean markup (which is a text in the format of XML
including all '<' and '>' tags. Not the text contained only within the
text nodes).

Is there any complete ready made function that serializes the NodeSet?
It seems like a very common problem. The example doesn't refer to all
node types and doesn't use escaping characters.
Maybe another option is selecting a single node (only the root of the
sub-tree) and convert the sub-tree to a Xerces DOM tree. Is this
possible?
If I have a Xerces DOM tree, I know how to serialize it easily.

If none of the options above is available, I guess I would have to write
the complete SerializeNodeSet by myself.

Ori.


-----Original Message-----
From: David Bertoni [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, March 14, 2007 5:01 PM
To: xalan-c-users@xml.apache.org
Subject: Re: Extracting a sub-tree as text using xpath

Ori Doolman wrote:
> Dave,
> What I need is to have in my hand (or code) a string that contains a
> sub-tree of the document (as XML).
> Of course I could just parse the document using Xerces and go to the
> node I need and serialize this sub-tree to text.
> But I want to do this using Xalan because there are other XPath
features
> I need.
> 
> I think that what you are suggesting is selecting all sub-tree nodes
> with /A/B//* and then go over the returned NodeRefList and create the
> XML text according to the node type (is there a ready made function
API
> for this common procedure??).

Yes, which is why I referred you to the SerializeNodeSet sample, which
does 
exactly that.  Did you look at it?  Also, when you say "XML text," it's 
ambiguous.  I think you mean markup, but I'm not sure.

> 
> So I'm beginning to understand that xpath can only be used for
selecting
> a collection of nodes from a document. The result of selected nodes
> doesn't refer to their original hierarchy in the DOM document tree. 

I don't know what to make of this comment, since it seems to contradict
itself.

An XPath location path addresses nodes in an instance of the data model.
A 
location path does not create anything, so the selected nodes _are_ the 
nodes in the original source tree.  However, XPath does not operate on 
markup, so there is no way to go back to the original markup.  The best
you 
can do is create new markup for any selected nodes.

Dave

> 
> Am I right here?
> 
> 
> 
> -----Original Message-----
> From: David Bertoni [mailto:[EMAIL PROTECTED] 
> Sent: Tuesday, March 13, 2007 12:10 AM
> To: xalan-c-users@xml.apache.org
> Subject: Re: Extracting a sub-tree as text using xpath
> 
> Ori Doolman wrote:
>> Someone, please?
>>
> I think what you mean is that you want the results as markup, and not
as
> 
> text, in the sense of text nodes in the data model.
> 
> Take a look at the SerializeNodeSet sample for more information.
> 
> Dave
> 

Reply via email to