Page 1 of 1

Issue unmarshalling paragraph

PostPosted: Thu Oct 22, 2009 10:01 am
by jbeltran
Hi,

Everytime I tried to unmarshall a paragraph using the following snippet of code:

Code: Select all
P paragraph = (P) XmlUtils.unmarshalString(paragraphString, Context.jc);


I get the following Exceception:

javax.xml.bind.UnmarshalException: unexpected element (uri:"", local:"p"). Expected elements are <{urn:schemas-microsoft-com:office:office}OLEObject>,<{urn:schemas-microsoft-com:vml}VMLFrame>,<{urn:schemas-microsoft-com:office:office}WordFieldCodes>,<{http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing}anchor>,<{http://schemas.openxmlformats.org/wordprocessingml/2006/main}annotationRef>,<{urn:schemas-microsoft-com:vml}arc>,<{urn:schemas-microsoft-com:vml}background>,<{http://schemas.openxmlformats.org/drawingml/2006/main}blip>,<{http://schemas.openxmlformats.org/wordprocessingml/2006/main}body>,<{http://schemas.openxmlformats.org/wordprocessingml/2006/main}bookmarkStart>,<{http://schemas.openxmlformats.org/wordprocessingml/2006/main}br>,<{urn:schemas-microsoft-com:office:office}callout>,<{http://schemas.openxmlformats.org/wordprocessingml/2006/main}color>,<{http://schemas.openxmlformats.org/wordprocessingml/2006/main}commentRangeEnd>,<{http://schemas.openxmlformats.org/wordprocessingml/2006/main}commentRangeStart>,<{http://schemas.openxmlformats.org/wordprocessingml/2006/main}commentReference>,<{http://schemas.openxmlformats.org/wordprocessingml/2006/main}comments>,<{urn:schemas-microsoft-com:office:office}complex>,<{http://schemas.openxmlformats.org/wordprocessingml/2006/main}continuationSeparator>,<{http://schemas.openxmlformats.org/wordprocessingml/2006/main}cr>,<{urn:schemas-microsoft-com:vml}curve>,<{http://schemas.openxmlformats.org/wordprocessingml/2006/main}dayLong>,<{http://schemas.openxmlformats.org/wordprocessingml/2006/main}dayShort>,<{http://schemas.openxmlformats.org/wordprocessingml/2006/main}del>,<{http://schemas.openxmlformats.org/wordprocessingml/2006/main}delText>,<{http://schemas.openxmlformats.org/wordprocessingml/2006/main}docDefaults>,<{http://schemas.openxmlformats.org/wordprocessingml/2006/main}document>,<{http://schemas.openxmlformats.org/wordprocessingml/2006/main}drawing>,<{http://schemas.openxmlformats.org/wordprocessingml/2006/main}endnoteRef>,<{http://schemas.openxmlformats.org/wordprocessingml/2006/main}endnotes>,<{urn:schemas-microsoft-com:office:office}extrusion>,<{urn:schemas-microsoft-com:vml}fill>,<{http://schemas.openxmlformats.org/wordprocessingml/2006/main}fonts>,<{http://schemas.openxmlformats.org/wordprocessingml/2006/main}footerReference>,<{http://schemas.openxmlformats.org/wordprocessingml/2006/main}footnoteRef>,<{http://schemas.openxmlformats.org/wordprocessingml/2006/main}footnotes>,<{urn:schemas-microsoft-com:vml}formulas>,<{http://schemas.openxmlformats.org/wordprocessingml/2006/main}ftr>,<{http://schemas.openxmlformats.org/wordprocessingml/2006/main}glossaryDocument>,<{http://schemas.openxmlformats.org/drawingml/2006/main}graphic>,<{urn:schemas-microsoft-com:vml}group>,<{urn:schemas-microsoft-com:vml}handles>,<{http://schemas.openxmlformats.org/wordprocessingml/2006/main}hdr>,<{http://schemas.openxmlformats.org/wordprocessingml/2006/main}headerReference>,<{http://schemas.openxmlformats.org/wordprocessingml/2006/main}highlight>,<{http://schemas.openxmlformats.org/wordprocessingml/2006/main}hyperlink>,<{http://schemas.openxmlformats.org/wordprocessingml/2006/main}id>,<{urn:schemas-microsoft-com:vml}image>,<{urn:schemas-microsoft-com:vml}imagedata>,<{http://schemas.openxmlformats.org/wordprocessingml/2006/main}ind>,<{http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing}inline>,<{http://schemas.openxmlformats.org/wordprocessingml/2006/main}ins>,<{http://schemas.openxmlformats.org/wordprocessingml/2006/main}jc>,<{http://schemas.openxmlformats.org/wordprocessingml/2006/main}lastRenderedPageBreak>,<{urn:schemas-microsoft-com:vml}line>,<{urn:schemas-microsoft-com:office:office}lock>,<{http://schemas.openxmlformats.org/officeDocument/2006/math}mathPr>,<{http://schemas.openxmlformats.org/wordprocessingml/2006/main}monthLong>,<{http://schemas.openxmlformats.org/wordprocessingml/2006/main}monthShort>,<{http://schemas.openxmlformats.org/wordprocessingml/2006/main}noBreakHyphen>,<{http://schemas.openxmlformats.org/wordprocessingml/2006/main}numPr>,<{http://schemas.openxmlformats.org/wordprocessingml/2006/main}numbering>,<{http://schemas.openxmlformats.org/officeDocument/2006/math}oMath>,<{http://schemas.openxmlformats.org/officeDocument/2006/math}oMathPara>,<{http://schemas.openxmlformats.org/wordprocessingml/2006/main}outlineLvl>,<{urn:schemas-microsoft-com:vml}oval>,<{http://schemas.openxmlformats.org/wordprocessingml/2006/main}p>,<{http://schemas.openxmlformats.org/wordprocessingml/2006/main}pBdr>,<{http://schemas.openxmlformats.org/wordprocessingml/2006/main}pPr>,<{http://schemas.microsoft.com/office/2006/xmlPackage}package>,<{urn:schemas-microsoft-com:vml}path>,<{http://schemas.openxmlformats.org/wordprocessingml/2006/main}pgNum>,<{http://schemas.openxmlformats.org/drawingml/2006/picture}pic>,<{urn:schemas-microsoft-com:vml}polyline>,<{http://schemas.openxmlformats.org/wordprocessingml/2006/main}proofErr>,<{http://schemas.openxmlformats.org/wordprocessingml/2006/main}ptab>,<{http://schemas.openxmlformats.org/wordprocessingml/2006/main}r>,<{http://schemas.openxmlformats.org/wordprocessingml/2006/main}rFonts>,<{http://schemas.openxmlformats.org/wordprocessingml/2006/main}rPr>,<{http://schemas.openxmlformats.org/wordprocessingml/2006/main}rStyle>,<{http://schemas.openxmlformats.org/wordprocessingml/2006/main}recipients>,<{urn:schemas-microsoft-com:vml}rect>,<{urn:schemas-microsoft-com:vml}roundrect>,<{http://schemas.openxmlformats.org/schemaLibrary/2006/main}schemaLibrary>,<{http://schemas.openxmlformats.org/wordprocessingml/2006/main}sdt>,<{http://schemas.openxmlformats.org/wordprocessingml/2006/main}sdtContent>,<{http://schemas.openxmlformats.org/wordprocessingml/2006/main}sdtPr>,<{http://schemas.openxmlformats.org/wordprocessingml/2006/main}sectPr>,<{http://schemas.openxmlformats.org/wordprocessingml/2006/main}separator>,<{http://schemas.openxmlformats.org/wordprocessingml/2006/main}settings>,<{urn:schemas-microsoft-com:vml}shadow>,<{urn:schemas-microsoft-com:vml}shape>,<{urn:schemas-microsoft-com:office:office}shapedefaults>,<{urn:schemas-microsoft-com:office:office}shapelayout>,<{urn:schemas-microsoft-com:vml}shapetype>,<{urn:schemas-microsoft-com:office:office}skew>,<{http://schemas.openxmlformats.org/wordprocessingml/2006/main}softHyphen>,<{http://schemas.openxmlformats.org/wordprocessingml/2006/main}spacing>,<{urn:schemas-microsoft-com:vml}stroke>,<{http://schemas.openxmlformats.org/wordprocessingml/2006/main}style>,<{http://schemas.openxmlformats.org/wordprocessingml/2006/main}styles>,<{http://schemas.openxmlformats.org/wordprocessingml/2006/main}sym>,<{http://schemas.openxmlformats.org/wordprocessingml/2006/main}t>,<{http://schemas.openxmlformats.org/wordprocessingml/2006/main}tab>,<{http://schemas.openxmlformats.org/wordprocessingml/2006/main}tabs>,<{http://schemas.openxmlformats.org/wordprocessingml/2006/main}tag>,<{http://schemas.openxmlformats.org/wordprocessingml/2006/main}tbl>,<{http://schemas.openxmlformats.org/wordprocessingml/2006/main}tc>,<{urn:schemas-microsoft-com:vml}textbox>,<{urn:schemas-microsoft-com:vml}textpath>,<{http://schemas.openxmlformats.org/drawingml/2006/main}theme>,<{http://schemas.openxmlformats.org/drawingml/2006/main}themeManager>,<{http://schemas.openxmlformats.org/drawingml/2006/main}themeOverride>,<{http://schemas.openxmlformats.org/wordprocessingml/2006/main}tr>,<{http://schemas.openxmlformats.org/wordprocessingml/2006/main}txbxContent>,<{http://schemas.openxmlformats.org/wordprocessingml/2006/main}u>,<{http://schemas.openxmlformats.org/wordprocessingml/2006/main}webSettings>,<{http://schemas.openxmlformats.org/wordprocessingml/2006/main}yearLong>,<{http://schemas.openxmlformats.org/wordprocessingml/2006/main}yearShort>

Below is the paragraph I'm trying to unmarshall:

Code: Select all
  <w:p>
    <w:pPr>
      <w:pStyle w:val="Footer" />
      <w:rPr>
        <w:rFonts w:ascii="Courier New" w:hAnsi="Courier New" w:cs="Courier New" />
      </w:rPr>
    </w:pPr>
    <w:r>
      <w:rPr>
        <w:noProof />
      </w:rPr>
      <w:pict>
        <v:shapetype id="_x0000_t202" coordsize="21600,21600" o:spt="202"
        path="m,l,21600r21600,l21600,xe">
          <v:stroke joinstyle="miter" />
          <v:path gradientshapeok="t" o:connecttype="rect" />
        </v:shapetype>
        <v:shape id="_x0000_s2049" type="#_x0000_t202"
        style="position:absolute;margin-left:10pt;margin-top:-17.15pt;width:24pt;height:52pt;z-index:251655680"
        filled="f" stroked="f">
          <v:textbox style="layout-flow:vertical">
            <w:txbxContent>
              <w:p>
                <w:pPr>
                  <w:pStyle w:val="Footer" />
                  <w:rPr>
                    <w:rFonts w:ascii="Courier New" w:hAnsi="Courier New" w:cs="Courier New" />
                  </w:rPr>
                </w:pPr>
                <w:r>
                  <w:rPr>
                    <w:rFonts w:ascii="Courier New" w:hAnsi="Courier New" w:cs="Courier New" />
                  </w:rPr>
                  <w:t xml:space="preserve">
PS -
</w:t>
                </w:r>
                <w:r>
                  <w:rPr>
                    <w:rFonts w:ascii="Courier New" w:hAnsi="Courier New" w:cs="Courier New" />
                  </w:rPr>
                  <w:fldChar w:fldCharType="begin" />
                </w:r>
                <w:r>
                  <w:rPr>
                    <w:rFonts w:ascii="Courier New" w:hAnsi="Courier New" w:cs="Courier New" />
                  </w:rPr>
                  <w:instrText xml:space="preserve">
PAGE  \* MERGEFORMAT
</w:instrText>
                </w:r>
                <w:r>
                  <w:rPr>
                    <w:rFonts w:ascii="Courier New" w:hAnsi="Courier New" w:cs="Courier New" />
                  </w:rPr>
                  <w:fldChar w:fldCharType="separate" />
                </w:r>
                <w:r>
                  <w:rPr>
                    <w:rFonts w:ascii="Courier New" w:hAnsi="Courier New" w:cs="Courier New" />
                    <w:noProof />
                  </w:rPr>
                  <w:t>6</w:t>
                </w:r>
                <w:r>
                  <w:rPr>
                    <w:rFonts w:ascii="Courier New" w:hAnsi="Courier New" w:cs="Courier New" />
                  </w:rPr>
                  <w:fldChar w:fldCharType="end" />
                </w:r>
              </w:p>
            </w:txbxContent>
          </v:textbox>
        </v:shape>
      </w:pict>
    </w:r>
  </w:p>


Am I using the wrong code to unmarshall that paragraph string? Do I need to use another method? Any info would be greatly appreciated!

Thanks,
Justin

Re: Issue unmarshalling paragraph

PostPosted: Thu Oct 22, 2009 10:47 am
by jason
Try declaring the namespace http://schemas.openxmlformats.org/wordp ... /2006/main for prefix w explicitly on the w:p element. Similarly for v: which is used in the paragraph.
cheers .. Jason