[SoapRMI] XB1 XPath

Andy Harrison andyh_at_agaricus.co.uk
Tue, 05 Apr 2005 11:06:05 +0100


To clarify, I'm trying to take a chunk from one document to create 
another. I think I could use XPath to get the nodeset I want, then 
create a new document with just that nodeset.

Xb1XPath xpath = new Xb1XPath("/path/to/my/nodeset");
XmlDocumentImpl newdoc = new XmlDocumentImpl();
newdoc.addChild(xpath.selectSingleNode(doc));

Xb1XPath xpathinside = new Xb1XPath("/path/inside/my/snippet");
Object myData = xpathinside.selectSingleNode(newdoc);

The above code doesn't work becuse I can't seem to be able to create a 
XmlDocumentImpl. The constructor takes (string,boolean,string) 
arguments, but it's not working for me. Hopefully someone can help me 
achieve what I'm looking for though?

thanks,
Andy


Andy Harrison wrote:
> Hi,
> 
> I've been looking at the sample given for XPath parsing in XPP3, a file 
> called "Xb1XpathDemo.java".
> 
> *****
> while ( resultsIter.hasNext() ) {
> Object infosetItem = resultsIter.next();
> System.out.println("----------------------------------"); 
> System.out.println(builder.serializeToString(infosetItem));
> }
> *****
> 
> To get more utility from this, ie access to child nodes in the returned 
> nodeset, do I just cast infosetItem to "XmlElementImpl"?
> 
> Also noticed that we are creating an XmlDocument from an 
> XmlInfosetBuilder, does this mean we have loaded the entire doc into 
> memory from the input stream? If this is the case, I only need to run 
> XPath against a fixed part of my document, so is there a simple way to 
> advance the input stream to the root node of the data that I wish to run 
>  XPath expressions against?
> 
> *****
> XmlInfosetBuilder builder = XmlInfosetBuilder.newInstance();
> XmlDocument doc = builder.parseInputStream(in);
> Xb1XPath xpath = new Xb1XPath("/body/div[2]");
> *****
> 
> Finally, does anyone know any more examples or tutorials for using XB1 
> and XPath?
> 
> thanks,
> Andy
> 
> _______________________________________________
> SoapRMI mailing list http://www.extreme.indiana.edu/soap
> http://mailman.cs.indiana.edu/mailman/listinfo/soaprmi
> 
>