dmitri      2004/01/23 17:12:02

  Modified:    jxpath/src/test/org/apache/commons/jxpath/ri/model
                        XMLModelTestCase.java
               jxpath/src/java/org/apache/commons/jxpath/ri/model/beans
                        NullPropertyPointer.java
  Log:
  Bug report 25609: Child not created when setting attribute
  
  Revision  Changes    Path
  1.17      +21 -6     
jakarta-commons/jxpath/src/test/org/apache/commons/jxpath/ri/model/XMLModelTestCase.java
  
  Index: XMLModelTestCase.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons/jxpath/src/test/org/apache/commons/jxpath/ri/model/XMLModelTestCase.java,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- XMLModelTestCase.java     19 Jan 2004 20:44:52 -0000      1.16
  +++ XMLModelTestCase.java     24 Jan 2004 01:12:01 -0000      1.17
  @@ -230,6 +230,12 @@
               "/vendor[1]/location[1]/@name",
               "local",
               "/vendor[1]/location[1]/@name");
  +
  +         assertXPathCreatePathAndSetValue(
  +            context,
  +            "/vendor[1]/location[4]/@manager",
  +            "",
  +            "/vendor[1]/location[4]/@manager");   
       }
   
       /**
  @@ -262,7 +268,13 @@
               "vendor/location[1]/@manager",
               "John Doe",
               "/vendor[1]/location[1]/@manager");
  -
  +        
  +        assertXPathCreatePathAndSetValue(
  +            context,
  +            "/vendor[1]/location[4]/@manager",
  +            "James Dow",
  +            "/vendor[1]/location[4]/@manager");
  +        
           assertXPathCreatePathAndSetValue(
               context,
               "vendor/product/name/attribute::price:language",
  @@ -343,7 +355,10 @@
               "priceNS:amount");
   
           // name (non-qualified)
  -        assertXPathValue(context, "name(vendor/location)", "location");
  +        assertXPathValue(
  +            context,
  +            "name(vendor/location)",
  +            "location");
   
           // namespace-uri (qualified)
           assertXPathValue(
  
  
  
  1.16      +9 -10     
jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/model/beans/NullPropertyPointer.java
  
  Index: NullPropertyPointer.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons/jxpath/src/java/org/apache/commons/jxpath/ri/model/beans/NullPropertyPointer.java,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- NullPropertyPointer.java  23 Jan 2004 01:10:21 -0000      1.15
  +++ NullPropertyPointer.java  24 Jan 2004 01:12:02 -0000      1.16
  @@ -146,8 +146,9 @@
       }
   
       public NodePointer createPath(JXPathContext context) {
  +        NodePointer newParent = parent.createPath(context);
           if (isAttribute()) {
  -            return parent.createAttribute(context, getName());
  +            return newParent.createAttribute(context, getName());
           }
           else {
               // Consider these two use cases:
  @@ -160,11 +161,9 @@
               // 2. The parent pointer of NullPropertyPointer is a NullPointer.
               //    When we call createPath, it may return a PropertyOwnerPointer
               //    or it may return anything else, like a DOMNodePointer.
  -            //    In the former case we need to exactly what we did in use 
  +            //    In the former case we need to do exactly what we did in use 
               //    case 1.  In the latter case, we simply request that the 
               //    non-property pointer expand the collection by itself.
  -
  -            NodePointer newParent = parent.createPath(context);
               if (newParent instanceof PropertyOwnerPointer) {
                   PropertyOwnerPointer pop = (PropertyOwnerPointer) newParent;
                   newParent = pop.getPropertyPointer();
  @@ -174,13 +173,13 @@
       }
   
       public NodePointer createPath(JXPathContext context, Object value) {
  +        NodePointer newParent = parent.createPath(context);
           if (isAttribute()) {
  -            NodePointer pointer = parent.createAttribute(context, getName());
  +            NodePointer pointer = newParent.createAttribute(context, getName());
               pointer.setValue(value);
               return pointer;
           }
           else {
  -            NodePointer newParent = parent.createPath(context);
               if (newParent instanceof PropertyOwnerPointer) {
                   PropertyOwnerPointer pop = (PropertyOwnerPointer) newParent;
                   newParent = pop.getPropertyPointer();
  
  
  

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

Reply via email to