You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xalan.apache.org by Pae Choi <pa...@earthlink.net> on 2002/11/24 08:12:43 UTC
1st parameter, "Node context Node" in the XPathAPI's methods
In XPathAPI, all methods has a first parameter, "Node contextNode",
and I am clear about that parameter.
Is that always referencing the root element of the DOM? Or, that
supposed to be reference any node in the DOM. Thanks.
Pae
Re: 1st parameter, "Node context Node" in the XPathAPI's methods
Posted by Pae Choi <pa...@earthlink.net>.
----- Original Message -----
From: "Pae Choi" <pa...@earthlink.net>
To: "Pae Choi" <pa...@earthlink.net>; <xa...@xml.apache.org>
Sent: Monday, November 25, 2002 8:45 AM
Subject: Re: 1st parameter, "Node context Node" in the XPathAPI's methods
> Continued from the privious post to be more specific.
>
> Say we have an XML document as follows:
>
> <!-- ########### XML Document ########## -->
> <PatientInfo>
> <Patient id="10099">
> <DemoInfo>
> <Age>39</Age>
> <Gender>Female</Gender>
> </DemoInfo>
> </Patient>
> </PatientInfo>
>
>
> // ########### Code Snippet ##############
> DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
> DocumentBuilder builder = null;
> Document xmlDoc = null;
> Node node = null;
> NodeIterator nodeIter = null;
>
> try {
> DocumentBuilder builder = factory.newDocumentBuilder();
> xmlDoc = builder.parse(filePath);
>
> node = XPathAPI.selectSingleNode(xmlDoc, "//Patient[@id="10099']/*");
> // The 'node' should reference the <DemoInfo> element. Right?
>
> // ******************** QUESTION ********************
> // The question is that whether the 'startNode' is referencing the
Oops. The 'startNode' should be 'node'.
> // <DemoInfo> element or the root element, <PatientInfo>.
> nodeIter = XPathAPI.selectNodeIterator(node, "./*");
>
> // I was thinking that the 'nodeIter' should return the list of
> // subelements, including the <Age> and <Gender>, but it does not.
> // That's why I am trying to find out whether the 1st parameter in
> // all methods of XPathAPI is referencing the root element of DOM
> // or any node of the DOM passed to it
> }
> catch (Exception ex) {
> ex.printStackTrace();
> }
>
> Any comments? Thanks.
>
>
> Pae
>
>
>
>
> > In XPathAPI, all methods has a first parameter, "Node contextNode",
> > and I am clear about that parameter.
> >
> > Is that always referencing the root element of the DOM? Or, that
> > supposed to be reference any node in the DOM. Thanks.
> >
> >
> > Pae
> >
> >
> >
> >
>
Re: 1st parameter, "Node context Node" in the XPathAPI's methods
Posted by Pae Choi <pa...@earthlink.net>.
Continued from the privious post to be more specific.
Say we have an XML document as follows:
<!-- ########### XML Document ########## -->
<PatientInfo>
<Patient id="10099">
<DemoInfo>
<Age>39</Age>
<Gender>Female</Gender>
</DemoInfo>
</Patient>
</PatientInfo>
// ########### Code Snippet ##############
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = null;
Document xmlDoc = null;
Node node = null;
NodeIterator nodeIter = null;
try {
DocumentBuilder builder = factory.newDocumentBuilder();
xmlDoc = builder.parse(filePath);
node = XPathAPI.selectSingleNode(xmlDoc, "//Patient[@id="10099']/*");
// The 'node' should reference the <DemoInfo> element. Right?
// ******************** QUESTION ********************
// The question is that whether the 'startNode' is referencing the
// <DemoInfo> element or the root element, <PatientInfo>.
nodeIter = XPathAPI.selectNodeIterator(node, "./*");
// I was thinking that the 'nodeIter' should return the list of
// subelements, including the <Age> and <Gender>, but it does not.
// That's why I am trying to find out whether the 1st parameter in
// all methods of XPathAPI is referencing the root element of DOM
// or any node of the DOM passed to it
}
catch (Exception ex) {
ex.printStackTrace();
}
Any comments? Thanks.
Pae
> In XPathAPI, all methods has a first parameter, "Node contextNode",
> and I am clear about that parameter.
>
> Is that always referencing the root element of the DOM? Or, that
> supposed to be reference any node in the DOM. Thanks.
>
>
> Pae
>
>
>
>
Re: 1st parameter, "Node context Node" in the XPathAPI's methods
Posted by Pae Choi <pa...@earthlink.net>.
I was hoping that, but did not work in that way. I have posted
source code, including the XML doc. If you see the Java code and
better to test it to see the result.
Pae
> From the Javadoc:
> contextNode - The node to start searching from.
>
> In other words, the note where evaluation of the XPath should start.
>
> ______________________________________
> Joe Kesselman / IBM Research
Re: 1st parameter, "Node context Node" in the XPathAPI's methods
Posted by Joseph Kesselman <ke...@us.ibm.com>.
>From the Javadoc:
contextNode - The node to start searching from.
In other words, the note where evaluation of the XPath should start.
______________________________________
Joe Kesselman / IBM Research