Uploaded image for project: 'XMLBeans'
  1. XMLBeans
  2. XMLBEANS-409

XPath on a copy() of an XMLBeans comp derived class fails

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: Version 2.4
    • Fix Version/s: None
    • Component/s: Cursor, DOM, XmlObject, XPath
    • Labels:
      None
    • Environment:
      Windows XP Professional
      JDK 1.6.0_07
      Saxon 9.0.0.4
      XMLBeans 2.4.0

      Description

      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
      }

        Attachments

          Activity

            People

            • Assignee:
              wypoon Wing Yew Poon
              Reporter:
              bworrell Bryan Worrell
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated: