King Nak wrote:
Hi!
I'm a novice to xalan and have a problem:
I've got a big XML file representing a product calalogue. here an example
excerpt:
<catalogue>
<chapter>
<!-- some more hierarchy -->
<product uid="12345">
<article-set>
<article uid="87"><!-- omitted --></article>
<article uid="88"><!-- omitted --></article>
<article uid="89"><!-- omitted --></article>
</article-set>
</product>
<product uid="7680">
<!-- a.s.o -->
</product>
</chapter>
</catalogue>
In my programm I have to process most (or all) of the elements having a uid
attribute one by one, no matter what kind of element they are.
I could use "//[EMAIL PROTECTED] = myuid]" everytime, but for performance
issues, I
want to cache the list of elements having a uid.
so I use "//[EMAIL PROTECTED]" to get these elements. this xpath gives me a
XNodeSetBase.
in further expressions, I have to select a specific element in this nodeset
by its uid.
in Xalan-C API reference, I found XObjectPtr::rtree() returning a const
XalanDocumentTreeFragment &. This class is a subclass of XalanNode and could
be used as a context for the XPathEvaluator (the const can be casted away,
see http://marc.theaimsgroup.com/?l=xalan-c-users&m=108145747222899&w=2
I don't know why you would want to cast a node-set to a result tree
fragment. You certainly wouldn't want to use this as the context for
another evaluation, since it would yield no results.
here )
but when I'm using this, a NULL-pointer is accessed. That's because
XObjectResultTreeFragProxyBase::getOwnerDocument() always returns 0, so I
can't get the nodeset's owner document...
is there any way to store a nodelist returned by an XPath to be used as the
context on another XPath?
Copy the nodes from the nodeset into your own container. You can use
std::vector<XalanNode*>, or Xalan-C's NodeRefList class:
NodeRefList cachedNodes(xobj->nodeset());
Dave