[prev in list] [next in list] [prev in thread] [next in thread] 

List:       xmlbeans-dev
Subject:    RE: Help with xmlbeans 2.2.0
From:       "Tony Dean" <Tony.Dean () sas ! com>
Date:       2006-07-26 12:36:17
Message-ID: C3BBBDFBE6D92C4EAA62BBE9793DECCF8BB33E () MERCMBX07 ! na ! sas ! com
[Download RAW message or body]

Raman,

Thank you very much.  This indeed is the cause of my woes.  When I use your code to \
convert from DocumentFragment to Document, the saxon xpath selectPath() call works as \
expected.

Again thank you for helping.

-Tony

-----Original Message-----
From: Raman Gupta [mailto:rocketraman@fastmail.fm] 
Sent: Tuesday, July 25, 2006 6:11 PM
To: dev@xmlbeans.apache.org
Cc: user@xmlbeans.apache.org
Subject: Re: Help with xmlbeans 2.2.0

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: user-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: user-help@xmlbeans.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: dev-help@xmlbeans.apache.org


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic