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 al...@cwazy.co.uk on 2003/12/07 08:30:01 UTC
Begginer question: Xalan XObjectPtr and evaluate
Hi,
I'm new to Xalan and this list...
I am using xalan's xpath api, and i want to return a XObjectPtr from my
function, but then, when i evaluate again, the app crashes, I read
somewhere that the XObjectPtr should not exist if the XPathEvaluator
doesn't exist anymore, or a new evaluation accurs, but what should i do in
this case? Is there a 'standart solution'?
And another question is what should i excpect to get from evaluate if the
evaluated xpath doesn't exist in a doc (or simply, how can i check if
something exists in my xml document?)
Thanks.
Alice.
RE: Begginer question: Xalan XObjectPtr and evaluate
Posted by Mark Weaver <ma...@npsl.co.uk>.
> But for the second part of my question...
> How can i know the xpath i'm evaluting has 'failed'?
>
It throws an exception (probably XPathException). I tend to do:
catch (const XSLException &e)
{
e.defaultFormat(errorMessage);
}
where errorMessage is a XalanDOMString.
Re: Begginer question: Xalan XObjectPtr and evaluate
Posted by da...@us.ibm.com.
Hi Alice,
If your XPath expression selects a node set, you will get an empty node set
if nothing was selected. If there is a syntactic or semantic error in your
expression, you will get an exception.
Dave
alice@cwazy.co.u
k To: xalan-c-users@xml.apache.org
cc: (bcc: David N Bertoni/Cambridge/IBM)
12/09/2003 05:37 Subject: Re: Begginer question: Xalan XObjectPtr and evaluate
AM
Thanks for the reply!
But for the second part of my question...
How can i know the xpath i'm evaluting has 'failed'?
Great Day :)
>
> Hi Alice,
>
> There is no "standard solution," because it depends on what kind of
object
> your XPath expression returns. If it's node set, the set will contain
> nodes in the source tree you passed into the evalution. All you need to
> do
> in that case is copy the node set, or copy the pointers out of the node
> set. If your expression evaluates to a boolean, string, or number, you
> can
> just make a copy of the value.
>
> NodeRefList nodeSet = xobjectPtr.nodeset();
> XalanDOMString str = xobjectPtr.str();
> ...
>
> At any rate, you must make sure the XObjectPtr instance is not in scope
> when the XPathEvaluator instance is destroyed, or when the next
evaluation
> occurs.
>
> Dave
>
>
>
>
> alice@cwazy.co.u
> k To:
> xalan-c-users@xml.apache.org
> cc: (bcc: David N
> Bertoni/Cambridge/IBM)
> 12/06/2003 11:30 Subject: Begginer
question:
> Xalan XObjectPtr and evaluate
> PM
>
>
>
>
> Hi,
> I'm new to Xalan and this list...
>
> I am using xalan's xpath api, and i want to return a XObjectPtr from my
> function, but then, when i evaluate again, the app crashes, I read
> somewhere that the XObjectPtr should not exist if the XPathEvaluator
> doesn't exist anymore, or a new evaluation accurs, but what should i do
in
> this case? Is there a 'standart solution'?
>
> And another question is what should i excpect to get from evaluate if the
> evaluated xpath doesn't exist in a doc (or simply, how can i check if
> something exists in my xml document?)
>
> Thanks.
> Alice.
>
>
>
>
Re: Begginer question: Xalan XObjectPtr and evaluate
Posted by al...@cwazy.co.uk.
Thanks for the reply!
But for the second part of my question...
How can i know the xpath i'm evaluting has 'failed'?
Great Day :)
>
> Hi Alice,
>
> There is no "standard solution," because it depends on what kind of object
> your XPath expression returns. If it's node set, the set will contain
> nodes in the source tree you passed into the evalution. All you need to
> do
> in that case is copy the node set, or copy the pointers out of the node
> set. If your expression evaluates to a boolean, string, or number, you
> can
> just make a copy of the value.
>
> NodeRefList nodeSet = xobjectPtr.nodeset();
> XalanDOMString str = xobjectPtr.str();
> ...
>
> At any rate, you must make sure the XObjectPtr instance is not in scope
> when the XPathEvaluator instance is destroyed, or when the next evaluation
> occurs.
>
> Dave
>
>
>
>
> alice@cwazy.co.u
> k To:
> xalan-c-users@xml.apache.org
> cc: (bcc: David N
> Bertoni/Cambridge/IBM)
> 12/06/2003 11:30 Subject: Begginer question:
> Xalan XObjectPtr and evaluate
> PM
>
>
>
>
> Hi,
> I'm new to Xalan and this list...
>
> I am using xalan's xpath api, and i want to return a XObjectPtr from my
> function, but then, when i evaluate again, the app crashes, I read
> somewhere that the XObjectPtr should not exist if the XPathEvaluator
> doesn't exist anymore, or a new evaluation accurs, but what should i do in
> this case? Is there a 'standart solution'?
>
> And another question is what should i excpect to get from evaluate if the
> evaluated xpath doesn't exist in a doc (or simply, how can i check if
> something exists in my xml document?)
>
> Thanks.
> Alice.
>
>
>
>
Re: Begginer question: Xalan XObjectPtr and evaluate
Posted by da...@us.ibm.com.
Hi Alice,
There is no "standard solution," because it depends on what kind of object
your XPath expression returns. If it's node set, the set will contain
nodes in the source tree you passed into the evalution. All you need to do
in that case is copy the node set, or copy the pointers out of the node
set. If your expression evaluates to a boolean, string, or number, you can
just make a copy of the value.
NodeRefList nodeSet = xobjectPtr.nodeset();
XalanDOMString str = xobjectPtr.str();
...
At any rate, you must make sure the XObjectPtr instance is not in scope
when the XPathEvaluator instance is destroyed, or when the next evaluation
occurs.
Dave
alice@cwazy.co.u
k To: xalan-c-users@xml.apache.org
cc: (bcc: David N Bertoni/Cambridge/IBM)
12/06/2003 11:30 Subject: Begginer question: Xalan XObjectPtr and evaluate
PM
Hi,
I'm new to Xalan and this list...
I am using xalan's xpath api, and i want to return a XObjectPtr from my
function, but then, when i evaluate again, the app crashes, I read
somewhere that the XObjectPtr should not exist if the XPathEvaluator
doesn't exist anymore, or a new evaluation accurs, but what should i do in
this case? Is there a 'standart solution'?
And another question is what should i excpect to get from evaluate if the
evaluated xpath doesn't exist in a doc (or simply, how can i check if
something exists in my xml document?)
Thanks.
Alice.