Changeset 1653 for trunk/docx4j/src/main


Ignore:
Timestamp:
09/05/11 13:38:33 (9 months ago)
Author:
jharrop
Message:

Handle unwrapping correctly in ShallowTraversor?, so JAXBElements stay wrapped, and we don't risk a marshalling exception for any which don't have an @XmlRootElement? annotation.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/docx4j/src/main/java/org/docx4j/model/datastorage/OpenDoPEHandler.java

    r1647 r1653  
    552552 
    553553                @Override 
    554                 public List<Object> apply(Object o) { 
     554                public List<Object> apply(Object wrapped) { 
    555555 
    556556                        // apply processSdt to any sdt 
    557557                        // which might be a conditional|repeat 
    558  
     558                        Object o = XmlUtils.unwrap(wrapped); 
    559559                        if (o instanceof org.docx4j.wml.SdtBlock 
    560560                                        || o instanceof org.docx4j.wml.SdtRun 
     
    574574                        // Otherwise just preserve the content 
    575575                        List<Object> newContent = new ArrayList<Object>(); 
    576                         newContent.add(o); 
     576                         
     577                        newContent.add(wrapped); // we want the JAXBElement (if any) 
    577578                        return newContent; 
    578579 
     
    607608                        } else { 
    608609                                for (Object o : children) { 
    609  
    610                                         newChildren.addAll(this.apply(XmlUtils.unwrap(o))); 
    611                                         // TODO: Post 2.7.0, review use of XmlUtils.unwrap(o) here; 
    612                                         // it can result in MarshalException for 
    613                                         // things which don't have @XmlRootElement. 
    614                                         // We really need some unit tests to be confident 
    615                                         // that making this change would be ok. 
     610                                        newChildren.addAll(this.apply(o)); 
    616611                                } 
    617612                        } 
     
    11521147                        // Sanity test 
    11531148                        if (!thisXPath.equals(xpathObj.getDataBinding().getXpath())) { 
    1154                                 log.error("XPaths didn't match for id " + bindingId + ": " 
     1149                                log.error("XPaths didn't match for id " + bindingId + ": \n\r    " + thisXPath + "\n\rcf. "  
    11551150                                                + xpathObj.getDataBinding().getXpath()); 
    11561151                        } 
Note: See TracChangeset for help on using the changeset viewer.