Hi,

Thanks for a very informative reply.

As you said point (c) was the mistake I had done. In my system's more complex code, i messed it up. But good I learnt something.
Also I tried with (d), everything works fine.

Thanks again.

Regards,
Rajath



From:        Michael Kay <mike@saxonica.com>
To:        saxon-help@lists.sourceforge.net
Date:        11/23/2012 03:15 PM
Subject:        Re: [saxon] Supplied node must be built using the same or a compatible Configuration




I can't see any reasons why you would get the "compatible Configuration" error with this code. However:

(a) your calls on evaluate() seem a bit confused. You are calling selector.evaluate() repeatedly; each call evaluates the first XPath expression, and you never use the result. You should remove both the call outside the for-each loop, and the call inside; iterating over the result of the expression using

for (XdmItem memberItem : selector)

should be enough. However, I don't think what you are doing should actually fail.

(b) I can't tell what the problem with
file:/D:/PSCR/  is about without access to your file system, but as the message says it's an XML parsing error and you need to fix it.

(c) The message about there being no context item for evaluating the second path expression ("Name") is presumably because you did

selector.setContextItem(memberNode2);


rather than

selector1.setContextItem(memberNode2);


(d) It might be simpler/faster to get the Name children of the elements selected by the first path expression using

memberNode2.axisIterator(Axis.CHILD, new QName("Name"))

although the method you are using is not wrong.

Michael Kay
Saxonica

On 23/11/2012 07:33, Rajath.Sakkari@continental-corporation.com wrote:
Hi Michael,

Thanks for your reply. To make it simple I am posting a small snippet that I tried.


Processor proc = new Processor(false);

XPathCompiler xpath = proc.newXPathCompiler();


DocumentBuilder builder = proc.newDocumentBuilder();

builder.setLineNumbering(true);

builder.setWhitespaceStrippingPolicy(WhitespaceStrippingPolicy.ALL);

XdmNode doc = builder.build(new File(file));

               
XPathSelector selector = xpath.compile("//Softcp/Infolink/Members[. = \"memberABC\"]").load();

selector.setContextItem(doc);

selector.evaluate();

               
for(XdmItem memberItem : selector) {

       XdmNode memberNode2 = (XdmNode) memberItem; //MemberNode is found here

       XPathSelector selector1 = xpath.compile("Name").load();

       selector.setContextItem(memberNode2);

       selector.evaluate();

       
       for(XdmItem NItem : selector1) {
 //error comes here now
                       //do something

       }

}


I hope  DocumentBuilder used here is of same Processor. Also I get a new error :(

org.xml.sax.SAXParseException; systemId:
file:/D:/PSCR/; lineNumber: 1; columnNumber: 1; Content is not allowed in prolog
net.sf.saxon.s9api.SaxonApiUncheckedException
: The context item for axis step child::Name is undefined

Am i missing something here?



Regards,

Rajath




From:        
Michael Kay <mike@saxonica.com>
To:        
saxon-help@lists.sourceforge.net
Date:        
11/22/2012 05:04 PM
Subject:        
Re: [saxon] Supplied node must be built using the same or a compatible Configuration





For "Configuration" here read "Processor", if everything is done using s9api. You should normally only create one Processor object. I strongly suspect that memberNode is built using a DocumentBuilder that belongs to a different Processor. The reason for the rule is that the Processor/Configuration owns the NamePool, and if your source document and XPath using different name pools, the matching of names will not work.

Michael Kay
Saxonica


On 22/11/2012 09:27,
Rajath.Sakkari@continental-corporation.com wrote:
Hello,


I am facing this error
Supplied node must be built using the same or a compatible Configuration.

I am using saxon9 and I have not done any complications. Here is what I did.


My Xpath was like this ex: //Softcp/Infolink/Members


I wanted a specific node so I changed it to //Softcp/Infolink/Members[. = ]


Now i got node Members as


XdmNode
memberNode which will have following value Ex:

<Members>

      <
Name>abc</Name>
      .        

      .

      .

</Members>


Now when i try to set only this node as context to get <Name> node


Processor proc = new Processor(false);

XPathCompiler xpathC = proc.newXPathCompiler();

XPathSelector selector = xpathC.compile("
Name").load();
selector.setContextItem(
memberNode); //error come here

What would be the problem here?

or am I doing it right?


What ultimately I wanted to achieve is, I do not want to iterate among thousands of nodes to find one unique node. I want an direct xpath to get that node based on the node value.


Regards,

Rajath


------------------------------------------------------------------------------
Monitor your physical, virtual and cloud infrastructure from a single
web console. Get in-depth insight into apps, servers, databases, vmware,
SAP, cloud infrastructure, etc. Download 30-day Free Trial.
Pricing starts from $795 for 25 servers or applications!

http://p.sf.net/sfu/zoho_dev2dev_nov


_______________________________________________
saxon-help mailing list archived at
http://saxon.markmail.org/
saxon-help@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/saxon-help
------------------------------------------------------------------------------
Monitor your physical, virtual and cloud infrastructure from a single
web console. Get in-depth insight into apps, servers, databases, vmware,
SAP, cloud infrastructure, etc. Download 30-day Free Trial.
Pricing starts from $795 for 25 servers or applications!

http://p.sf.net/sfu/zoho_dev2dev_nov_______________________________________________
saxon-help mailing list archived at
http://saxon.markmail.org/
saxon-help@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/saxon-help


------------------------------------------------------------------------------
Monitor your physical, virtual and cloud infrastructure from a single
web console. Get in-depth insight into apps, servers, databases, vmware,
SAP, cloud infrastructure, etc. Download 30-day Free Trial.
Pricing starts from $795 for 25 servers or applications!
http://p.sf.net/sfu/zoho_dev2dev_nov


_______________________________________________
saxon-help mailing list archived at
http://saxon.markmail.org/
saxon-help@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/saxon-help
------------------------------------------------------------------------------
Monitor your physical, virtual and cloud infrastructure from a single
web console. Get in-depth insight into apps, servers, databases, vmware,
SAP, cloud infrastructure, etc. Download 30-day Free Trial.
Pricing starts from $795 for 25 servers or applications!
http://p.sf.net/sfu/zoho_dev2dev_nov_______________________________________________
saxon-help mailing list archived at
http://saxon.markmail.org/
saxon-help@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/saxon-help