Dave,

Posting another time as my previous message does not seem to be delivered.

SimpleXPathAPI is doing:
XalanNode* const        theContextNode =
                                        theEvaluator.selectSingleNode(
                                        theDOMSupport,
                                        theDocument,
                                        XalanDOMString(argv[2]).c_str(),
                                        thePrefixResolver);
...

const XObjectPtr        theResult(
                                theEvaluator.evaluate(
                                theDOMSupport,
                                theContextNode,
                                XalanDOMString(argv[3]).c_str(),
                                thePrefixResolver));

Here theResult->str() returns the string id('id1').

Now I have added the following (though not working):
String myStr;
xalanc::XalanVector<char> data;
theResult->str().transcode(data);
myStr.assign(data.begin(), data.end());


const XObjectPtr        theResult1(
                                theEvaluator.evaluate(
                                theDOMSupport,
                                theContextNode,
                                XalanDOMString(myStr.c_str()).c_str(),
                                thePrefixResolver));
Here theResult1->str() returns a blank string now.

Will you tell me what needs to be done here to evaluate the expression 
id('id1') to fetch the text data
corresponding to the element whose id is id1.
Could you please attach some code snippet. That would be really helpful for me 
as I'm new in this area,
and have to do programming with Xalan fast !

Thanks in advance.

-Indrajit  


On Mon, 12 Feb 2007 David Bertoni wrote :
>Indrajit Bhattacharya wrote:
>>Hi Dave,
>>
>>1. I'm using VC7.1.3088 (.Net framework SP1) on Windows XP Professional.
>
>Then you shouldn't have any problem building the binaries if you follow the 
>build instructions.  I use VS .Net 2003 as my primary development platform.
>
>>
>>2. Here I did not put it correctly. (pls. forgive me as I'm quite new to XML, 
>>Xalan and XPath).
>>
>>Pls. see the problem I'm into below:
>>
>>I have some XML like:
>><A>
>>      <B>
>>           <C1 id="id1">1</C1>
>>           <C2 id="id2">2</C2>
>>      </B>
>>      <D id="id('id1')">3</D>
>></A>
>>
>>When I give XPath expression like : /A/D/@id , I need to get value 1. The 
>>value 1 will be coming from the element C1 whose id is "id1".
>>Please let me know how I can do the same, and how I can get the desired value 
>>using the sample applications with Xalan.
>
>The sample XPath applications that ship with Xalan-C would need to be modified 
>to do something like this, although you could do it with a stylesheet and an 
>extension function.
>
>>
>>Currently I'm getting the string output id('id1'). In fact I need to get 
>>value 1 (this corresponds to the value of the element whose id is id1).
>
>Since you want to use an XPath expression to select an attribute with another 
>value that should also be evaluated as an XPath expression, you
>just need to add another evaluation.  It should be very straightforward to 
>modify the SimpleXPathAPI sample to do that.
>
>Dave

Reply via email to