David Bertoni wrote:
>
> kamakshi wrote:
>> hi,
>> <Select>
>> <SearchFilter></SearchFilter>
>> <Component>http://3gpp/ap/bs</Component>
>> <GL>/Profile/Sub/App</GL>
>> </Select>
>> This is my xml....
>> now i want to use an xpath to find the details of App using the GL
>> only............
>> i tried using the xpath:
>> Select/GL,
>> but this returns only the value of GL as a string, is there any way of
>> evaluating the content of a node as xpath? can anybody help me out?
>
> Without more information about what you're doing, it's hard to say how you
> should solve this problem. If this is part of a stylesheet, you can use
> the EXSLT function evaluate():
>
> http://www.exslt.org/dyn/functions/evaluate/index.html
>
> There is no way with standard XSLT to do dynamic evaluation of XPath
> expressions within a stylesheet.
>
> If you're writing code to do this work, you can use the XPathEvaluator
> class to compile and evaluate the XPath expression. There is a sample
> application that illustrates how to use that class.
>
> Dave
>
>
>
i will describe about what i am doing in detail.....
Iam not using a stylesheet i am using a xml file testmodify.xml that
contains a dom tree, where one of the nodes values itself is an xpath
pointing to another node in the same dom tree.
<IS>
<Select>
<SearchFilter></SearchFilter>
<Component>http://3gpp/gup/ns/comp/C_Sub/C_App</Component>
<GL>/IS/Profile/C_Subscription/C_AppP[AppProfileIdentifier="app1"]</GL>
</Select>
<Profile>
<C_Subscription>
<C_AppP>
<AppProfileIdentifier>app1</AppProfileIdentifier>
<IUReference>sip:impu1</IUReference>
<SubRef>sub1</SubRef>
<AppData><Acro>CLIP</Acro><Sub>true</Sub><ActivationOptions><SubscriberControlAllowed>true</SubscriberControlAllowed><Activation>true</Activation></ActivationOptions></AppData>
</C_AppP>
</C_Subscription>
</Profile>
</IS>
I am using a SimplaXPathAPI.cpp(sample file given in xalan) file to evaluate
the given xpath...
The code i am using is
NodeRefList itemList;
theEvaluator.selectNodeList(
itemList,
theDOMSupport,
theContextNode,
XalanDOMString(argv[3]).c_str(),
thePrefixResolver);
const NodeRefList::size_type
theLength = itemList.getLength();
if (theLength == 0)
{
cerr << endl
<< "Warning: No nodes
matched the location path \""
<< argv[3]
<< "\"."
<< endl;
}
else
{
XALAN_USING_XALAN(XalanStdOutputStream)
XALAN_USING_XALAN(XalanOutputStreamPrintWriter)
XALAN_USING_XALAN(FormatterToXML)
XALAN_USING_XALAN(FormatterTreeWalker)
// OK, we're going to serialize
the nodes that were
// found. We should really
check to make sure the
// root (document) has not been
selected, since we
// really can't serialize a
node list with the root.
XalanStdOutputStream
theStream(cout);
XalanOutputStreamPrintWriter
thePrintWriter(theStream);
FormatterToXML
theFormatter(thePrintWriter);
FormatterTreeWalker
theWalker(theFormatter);
// Don't write a header...
theFormatter.setShouldWriteXMLHeader(false);
// It's required that we do
this...
theFormatter.startDocument();
// Traverse the subtree of the
document rooted at
// each node we've selected...
for (NodeRefList::size_type i =
0; i < theLength; ++i)
{
const XalanNode* const
theNode = itemList.item(i);
assert(theNode != 0);
const
XalanNode::NodeType theNodeType =
theNode->getNodeType();
if (theNodeType ==
XalanNode::DOCUMENT_NODE)
{
cerr
<<"Warning: The root was selected. The root cannot be
serialized."<< endl;
}
else if (theNodeType ==
XalanNode::ATTRIBUTE_NODE)
{
cerr
<<"Warning: An attribute or namespace node was selected.
Attribute and namespace nodes cannot be serialized."<< endl;
}
else
{
theWalker.traverseSubtree(theNode);
}
}
// It's required that we do
this...
theFormatter.endDocument();
}
The xpath what i want to evaluate is ::
SimpleXPathAPI testmodify.xml / '/IS/Select/GL' where GL inturn should
evaluate its xpath and final output should be AppP data..........
can u help me out with these details?
--
View this message in context:
http://www.nabble.com/how-to-evaluate-a-xpath-%2Cthat-is-the-value-for-a-node-in-the-given-xpath-tf2557995.html#a7152117
Sent from the Xalan - C - Users mailing list archive at Nabble.com.