You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-users@xalan.apache.org by Jaspreet Singh <Ja...@quark.co.in> on 2003/10/28 14:26:31 UTC

xpath evaluation using xalan

Hi All

I am trying to evaluate an xpath expression using xalan. i'm using the
xpathwrapper sample for this. i have a few questions -

it seems that the parserLiason, envSupport, constructionContext,
documentWrapper, wrapperNavigator, and all other classes that are used as
glue code should be "live" when we access the return value (xobject). if
these objects are destroyed, the xobject return value is invalidated.
if i return the xobject to some other class and the above mentioned objects
are destroyed, i am unable to access the return value. so i've declared
these as static. is this the way to use the lib?

i get a lot of asserts while evaluating some expressions. the assertion
looks like "node1.isIndexed() == true && node2.isIndexed() == true". I can
avoid the assertions by modifying the xpath expression. but in some cases i
just can't get rid of it. could you pls tell me the reason for this assert?


Thanks,
Jaspreet


RE: xpath evaluation using xalan

Posted by Erik Rydgren <er...@mandarinen.se>.
Regarding the assert. My guess is that you have told the documentWrapper
not to index the whole document. That is why the nodes in the assertion
aren't indexed. Tell the documentWrapper to buildWrapper and buildMap in
the constructor.

/ Erik

> -----Original Message-----
> From: Jaspreet Singh [mailto:Jasingh@quark.co.in]
> Sent: den 28 oktober 2003 14:27
> To: xalan-c-users@xml.apache.org
> Subject: xpath evaluation using xalan
> 
> Hi All
> 
> I am trying to evaluate an xpath expression using xalan. i'm using the
> xpathwrapper sample for this. i have a few questions -
> 
> it seems that the parserLiason, envSupport, constructionContext,
> documentWrapper, wrapperNavigator, and all other classes that are used
as
> glue code should be "live" when we access the return value (xobject).
if
> these objects are destroyed, the xobject return value is invalidated.
> if i return the xobject to some other class and the above mentioned
> objects
> are destroyed, i am unable to access the return value. so i've
declared
> these as static. is this the way to use the lib?
> 
> i get a lot of asserts while evaluating some expressions. the
assertion
> looks like "node1.isIndexed() == true && node2.isIndexed() == true". I
can
> avoid the assertions by modifying the xpath expression. but in some
cases
> i
> just can't get rid of it. could you pls tell me the reason for this
> assert?
> 
> 
> Thanks,
> Jaspreet



Re: xpath evaluation using xalan

Posted by da...@us.ibm.com.



> Hi All
>
> I am trying to evaluate an xpath expression using xalan. i'm using the
> xpathwrapper sample for this. i have a few questions -
>
> it seems that the parserLiason, envSupport, constructionContext,
> documentWrapper, wrapperNavigator, and all other classes that are used as
> glue code should be "live" when we access the return value (xobject). if
> these objects are destroyed, the xobject return value is invalidated.
> if i return the xobject to some other class and the above mentioned
objects
> are destroyed, i am unable to access the return value. so i've declared
> these as static. is this the way to use the lib?

Static would be a bad idea.  They do need to be "live", but they should be
wrapped up in some class or classes of your own devising that have the same
lifetime as the XObject instance.

> i get a lot of asserts while evaluating some expressions. the assertion
> looks like "node1.isIndexed() == true && node2.isIndexed() == true". I
can
> avoid the assertions by modifying the xpath expression. but in some cases
i
> just can't get rid of it. could you pls tell me the reason for this
assert?

I think you're misusing the library.  You should only use
XalanSourceTreeDOMSupport if you're using Xalan's default source tree
implementation.  It sounds like you're using one of the wrappers, so you
need to use XercesDOMSupport.

Look at the sample SimpleXPathAPI and use the XPathEvaluator class, rather
than using the code in XPathWrapper.cpp.  It has a higher level of
abstraction, and will make things a bit easier for you.

Dave