I'm trying to save specific parts of my docx files using marshalling and serialization. Unfortunalty the unmarshalling call to the following String causes the JaxbValidationEventHandler to result in an Error.
- Code: Select all
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<w:sdt xmlns:ns16="http://opendope.org/conditions" xmlns:ns17="http://opendope.org/questions" xmlns:ns15="http://opendope.org/xpaths" xmlns:c="http://schemas.openxmlformats.org/drawingml/2006/chart" xmlns:ns18="http://opendope.org/components" xmlns:ns19="http://schemas.openxmlformats.org/drawingml/2006/compatibility" xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" xmlns:ns9="http://schemas.openxmlformats.org/drawingml/2006/chartDrawing" xmlns:wp="http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing" xmlns:pkg="http://schemas.microsoft.com/office/2006/xmlPackage" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:m="http://schemas.openxmlformats.org/officeDocument/2006/math" xmlns:pic="http://schemas.openxmlformats.org/drawingml/2006/picture" xmlns:ns12="http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing" xmlns:ns7="http://schemas.openxmlformats.org/schemaLibrary/2006/main" xmlns:ns10="http://schemas.openxmlformats.org/drawingml/2006/diagram" xmlns:ns20="http://schemas.openxmlformats.org/drawingml/2006/lockedCanvas" xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships">
<w:sdtPr>
<w:rPr>
<w:rFonts w:cs="Arial"/>
<w:b/>
<w:color w:themeColor="text1" w:val="000000"/>
<w:sz w:val="20"/>
<w:szCs w:val="20"/>
</w:rPr>
<w:alias w:val="engagementfuehrer_x590"/>
<w:tag w:val="engagementfuehrer_x590"/>
<w:id w:val="-1455363377"/>
<w:lock w:val="sdtContentLocked"/>
<w:placeholder>
<w:docPart w:val="DefaultPlaceholder_22675703"/>
</w:placeholder>
</w:sdtPr>
<w:sdtContent>
<w:p w:rsidRDefault="006656FA" w:rsidP="00A065B1" w:rsidR="006656FA" w:rsidRPr="006656FA">
<w:pPr>
<w:rPr>
<w:rFonts w:cs="Arial"/>
<w:b/>
<w:color w:themeColor="text1" w:val="000000"/>
<w:sz w:val="20"/>
<w:szCs w:val="20"/>
</w:rPr>
</w:pPr>
<w:r w:rsidRPr="006656FA">
<w:rPr>
<w:rFonts w:cs="Arial"/>
<w:b/>
<w:color w:themeColor="text1" w:val="000000"/>
<w:sz w:val="20"/>
<w:szCs w:val="20"/>
</w:rPr>
<w:t>
engagementfuehrer_x59
</w:t>
</w:r>
<w:r w:rsidR="00A065B1">
<w:rPr>
<w:rFonts w:cs="Arial"/>
<w:b/>
<w:color w:themeColor="text1" w:val="000000"/>
<w:sz w:val="20"/>
<w:szCs w:val="20"/>
</w:rPr>
<w:t>
0
</w:t>
</w:r>
</w:p>
</w:sdtContent>
</w:sdt>
This String is an marshalled SdtElement with one embedded paragraph.
The error message interesstingly is cut at the end so this is no copy/paste error:
- Code: Select all
2011-04-06 10:12:07,411 WARN JaxbValidationEventHandler - [ERROR] : unexpected element (uri:"http://schemas.openxmlformats.org/wordprocessingml/2006/main", local:"p"). Expected elements ar
2011-04-06 10:12:07,411 INFO JaxbValidationEventHandler - continuing (with possible element/attribute loss)
Other unmarshalled SdtElements get the same error as many times as paragraphs occur in it. Of course, in the result no element is returned.
I've tried to create a minimal example by creating a sdtBlock and adding a paragraph to its content. Marshalling and Unmarshalling fails for this example, too!
Using java Syntax Highlighting
P paragraph = new P();
paragraph.setRsidRDefault("006656FA");
paragraph.setRsidP("00A065B1");
paragraph.setRsidR("006656FA");
paragraph.setRsidRPr("006656FA");
SdtContentBlock content = new SdtContentBlock();
SdtBlock sdtElem = Context.getWmlObjectFactory().createSdtBlock();
sdtElem.setSdtContent(content);
sdtElem.getContent().getContent().add(paragraph);
String s = XmlUtils.marshaltoString(sdtElem, true);
Object o2 = XmlUtils.unmarshalString(s);
paragraph.setRsidRDefault("006656FA");
paragraph.setRsidP("00A065B1");
paragraph.setRsidR("006656FA");
paragraph.setRsidRPr("006656FA");
SdtContentBlock content = new SdtContentBlock();
SdtBlock sdtElem = Context.getWmlObjectFactory().createSdtBlock();
sdtElem.setSdtContent(content);
sdtElem.getContent().getContent().add(paragraph);
String s = XmlUtils.marshaltoString(sdtElem, true);
Object o2 = XmlUtils.unmarshalString(s);
Parsed in 0.015 seconds, using GeSHi 1.0.8.4
Can you help me out on this, please?
Richard