You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xmlbeans.apache.org by "Harry Wambolt (JIRA)" <xm...@xml.apache.org> on 2009/06/18 14:17:07 UTC

[jira] Commented: (XMLBEANS-409) XPath on a copy() of an XMLBeans comp derived class fails

    [ https://issues.apache.org/jira/browse/XMLBEANS-409?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12721218#action_12721218 ] 

Harry Wambolt commented on XMLBEANS-409:
----------------------------------------

Changing org.apache.xmlbeans.impl.xpath.saxon.XBeansXPath, method selectNodes, line(s)

            NodeInfo contextItem = 
                //config.buildDocument(new DOMSource(contextNode));
                config.unravel(new DOMSource(contextNode));

to
           DocumentWrapper contextItem =
                new DocumentWrapper(contextNode, contextNode.getNamespaceURI(), config);

appears to restore XPath capabilities for document fragments.  The XQuery adapter
org.apache.xmlbeans.impl.xquery.saxon.XBeansXQuery may require modification as well.

> XPath on a copy() of an XMLBeans comp derived class fails 
> ----------------------------------------------------------
>
>                 Key: XMLBEANS-409
>                 URL: https://issues.apache.org/jira/browse/XMLBEANS-409
>             Project: XMLBeans
>          Issue Type: Bug
>          Components: Cursor, DOM, XmlObject, XPath
>    Affects Versions: Version 2.4 
>         Environment: Windows XP Professional
> JDK 1.6.0_07
> Saxon 9.0.0.4
> XMLBeans 2.4.0
>            Reporter: Bryan Worrell
>
> I can execute an XPath on an XMLBeans derived class using selectPath(...) and it will behave as expected; returning 0-n results in an XmlObject[] array.  However, if I create a copy of the object and execute an XPath on it, every XPath will return a zero-length array.
> The examples behave properly with XMLBeans 2.3.0 with Saxon 8.8.  I noticed this issue when I switched to XMLBeans 2.4.0 and Saxon 9.0.0.4.  The issue remains if I use XMLBeans 2.4.0 and Saxon 9.1.0.6 (the current release at the time of this posting).
> So, given this example:
> <AppDoc>
>   <Applications>
>     <ApplicationType>
>       <Name>foobar</Name>
>     </ApplicationType>
>   <Applications>
> </AppDoc>
> /**
>  Say we pass in the ApplicationType object with the Name of "foobar"
>  **/
> public void confuseTheDeveloper( ApplicationType app ){
>   String xPath = "$this/*:Name";
>   ApplicationType appCopy = (ApplicationType)app.copy();  
>   XmlObject[] objs = app.selectPath( xPath );
>   XmlObject[] otherObjs = appCopy.selectPath( xPath );
>   System.out.prinln( objs.length > 0 );  // prints 'true'  ... like it should
>   System.out.println( otherObjs.length > 0 ); // prints 'false'   ...even though it should print 'true'
> }
> /**
>  Another example
>  **/
> public void moreConfusion(){
>   ApplicationType app = ApplicationType.Factory.newInstance();
>   app.setName( "foobar" );
>   
>   XmlObject[] objs = app.selectPath( "$this/*:Name" );
>   System.out.println( objs.length > 0 );  // prints false
> }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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