Tony Dean wrote:
Hi, I determined that it's not jre dependent. That is I can get it to fail on 1.4.x or 5.0. I also determined that I can run the XQueryXPath sample without any problems which performs xpath query with predicate. So that got me thinking about what is the difference between the two scenarios: (1) my scenario -
I create an XmlObject from scratch as follows:
XmlObject.Factory.newInstance();
This actually creates a XmlAnyTypeImpl object with _textsource = Xobj$DocumentFragXobj. When xmlbeans uses the saxon engine in this case since the xmlbeans engine can't handle predicates, it does so by calling:
Path$SaxonPathImpl$SaxonPathEngine class ->
context_node = Xobj$DocumentFragXobj
resultsList = _saxonXpathImpl.selectPath(context_node)
...
DOMSource rootNode = new DOMSource(context_node)
XpathEvaluator xpe = new XPathEvaluator()
XBeansIndependentContext sc = ...
xpe.setStaticContext(sc)
...
Variable thisVar = sc.declareVariable("this")
thisVar.setValue(rootNode)
this throws a classcast exception : org.apache.xmlbeans.impl.store.Xobj$DocumentFragXobj net.sf.saxon.trans.Variable can not properly cast org.apache.xmlbeans.impl.store.Xobj$DocumentFragXobj object type (2) case that works The underlying XmlAnyTypeImpl _textsource object = Xobj$DocumentXobj, not Xobj$DocumentFragXobj.
This seems to be the issue I describe in this bug:

http://issues.apache.org/jira/browse/XMLBEANS-200

Yana explains the reason for the problem in the bug report, but as my last comment indicated I think there are some inconsistencies in how XmlBeans is behaving.

As I describe in the bug, I workaround the problem by always calling:

if(((XmlObject)input).getDomNode() instanceof DocumentFragment) {
   input = XmlObject.Factory.parse(((XmlObject)input).getDomNode());
}

before doing any Xquery or XSL transformations on an XmlObject with Saxon.

Cheers,
Raman

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to