Hi, 
I'm following from an earlier suggestion to make  XMLTableModel
updates.  The method was to use XPath to map back from the table
row/col to the Node at this location in the document.

The following code does update the document (via the node handle)
but at the wrong place - always at the second last row. 
 
public void setValueAt(Object o, int row, int col) { 
  
  Object object = definition.getRowXPath().selectNodes(source);

  if ( object instanceof List ) {
    List list = (List) object;
    for ( Iterator iter = list.iterator(); iter.hasNext(); ) {
       Object obj =  iter.next();
      
       org.dom4j.tree.DefaultElement defaultElement =            
         (org.dom4j.tree.DefaultElement) obj;

                 System.err.println( "rowIndex:" + row );
                 System.err.println( "nodeCount:" + defaultElement.nodeCount()  );
                 System.err.println( "name:" + ((org.dom4j.Node)
defaultElement.node(row)).getName() );
                 System.err.println( "parent:" + defaultElement.getParent());
            
                 org.dom4j.Node node = defaultElement.node(row);

                 if (defaultElement.nodeCount() ==1) {
                   node.setText("****NEW*VALUE****");
                   return;
                 }
             }        
         }




The xml data file is follows:-
<?xml version="1.0"?>

<EngineeringSpecification 
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
      xsi:noNamespaceSchemaLocation="spec.xsd">

<Summary>
 <device>F711111</device>
</Summary>
<Summary>
 <device>F722222</device>
</Summary>
<Summary>
 <device>F733333</device>
</Summary>
<Summary>
 <device>F744444</device>
</Summary>
<Summary>
 <device>F755555</device>
</Summary>

</EngineeringSpecification>

-- 
John.


-------------------------------------------------------
This sf.net email is sponsored by: To learn the basics of securing 
your web site with SSL, click here to get a FREE TRIAL of a Thawte 
Server Certificate: http://www.gothawte.com/rd524.html
_______________________________________________
dom4j-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/dom4j-user

Reply via email to