0

This is a typical structure of a <w:r> which contains shape(s).

<w:r w:rsidR="00D10BFA">
<w:rPr>
    <w:noProof/>
    <w:lang w:eastAsia="en-PH" />
</w:rPr>
<mc:AlternateContent>
    <mc:Choice Requires="wps">
        <w:drawing>
            <wp:anchor distT="0" distB="0" distL="114300" distR="114300" simplePos="0" relativeHeight="251660288" behindDoc="0" locked="0" layoutInCell="1" allowOverlap="1">
                <wp:simplePos x="0" y="0" />
                <wp:positionH relativeFrom="column">
                    <wp:posOffset>2171700</wp:posOffset>
                </wp:positionH>
                <wp:positionV relativeFrom="paragraph">
                    <wp:posOffset>99203</wp:posOffset>
                </wp:positionV>
                <wp:extent cx="1943100" cy="1714500" />
                <wp:effectExtent l="19050" t="19050" r="19050" b="19050" />
                <wp:wrapNone/>
                <wp:docPr id="2" name="Oval 2" />
                <wp:cNvGraphicFramePr/>
                <a:graphic xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main">
                    <a:graphicData uri="http://schemas.microsoft.com/office/word/2010/wordprocessingShape">
                        <wps:wsp>
                            <wps:cNvSpPr/>
                            <wps:spPr>
                                <a:xfrm>
                                    <a:off x="0" y="0" />
                                    <a:ext cx="1943100" cy="1714500" />
                                </a:xfrm>
                                <a:prstGeom prst="ellipse">
                                    <a:avLst/>
                                </a:prstGeom>
                                <a:solidFill>
                                    <a:schemeClr val="accent4">
                                        <a:lumMod val="75000" />
                                    </a:schemeClr>
                                </a:solidFill>
                                <a:ln w="28575" cap="sq">
                                    <a:solidFill>
                                        <a:schemeClr val="accent6">
                                            <a:lumMod val="75000" />
                                        </a:schemeClr>
                                    </a:solidFill>
                                </a:ln>
                            </wps:spPr>
                            <wps:style>
                                <a:lnRef idx="2">
                                    <a:schemeClr val="accent1">
                                        <a:shade val="50000" />
                                    </a:schemeClr>
                                </a:lnRef>
                                <a:fillRef idx="1">
                                    <a:schemeClr val="accent1" />
                                </a:fillRef>
                                <a:effectRef idx="0">
                                    <a:schemeClr val="accent1" />
                                </a:effectRef>
                                <a:fontRef idx="minor">
                                    <a:schemeClr val="lt1" />
                                </a:fontRef>
                            </wps:style>
                            <wps:txbx>
                                <w:txbxContent>
                                    <w:p w:rsidR="00D10BFA" w:rsidRDefault="00D10BFA" w:rsidP="00D10BFA">
                                        <w:pPr>
                                            <w:jc w:val="center" />
                                        </w:pPr>
                                        <w:r>
                                            <w:t>THEQUICKBROWNFOXJUMPSOVERTHELAZYDOG.THEQUICKBROWNFOXJUMPSOVERTHELAZYDOG.THEQUICKBROWFA</w:t>
                                        </w:r>
                                    </w:p>
                                </w:txbxContent>
                            </wps:txbx>
                            <wps:bodyPr rot="0" spcFirstLastPara="0" vertOverflow="overflow" horzOverflow="overflow" vert="horz" wrap="square" lIns="91440" tIns="45720" rIns="91440" bIns="45720" numCol="1" spcCol="0" rtlCol="0" fromWordArt="0" anchor="ctr" anchorCtr="0" forceAA="0" compatLnSpc="1">
                                <a:prstTxWarp prst="textNoShape">
                                    <a:avLst/>
                                </a:prstTxWarp>
                                <a:noAutofit/>
                            </wps:bodyPr>
                        </wps:wsp>
                    </a:graphicData>
                </a:graphic>
            </wp:anchor>
        </w:drawing>
    </mc:Choice>
    <mc:Fallback>
        <w:pict>
            <v:oval id="Oval 2" o:spid="_x0000_s1028" style="position:absolute;margin-left:171pt;margin-top:7.8pt;width:153pt;height:135pt;z-index:251660288;visibility:visible;mso-wrap-style:square;mso-wrap-distance-left:9pt;mso-wrap-distance-top:0;mso-wrap-distance-right:9pt;mso-wrap-distance-bottom:0;mso-position-horizontal:absolute;mso-position-horizontal-relative:text;mso-position-vertical:absolute;mso-position-vertical-relative:text;v-text-anchor:middle" o:gfxdata="UEsDBBQABgAIAAAAIQC2gziS/gAAAOEBAAATAAAAW0NvbnRlbnRfVHlwZXNdLnhtbJSRQU7DMBBF&#xA;90jcwfIWJU67QAgl6YK0S0CoHGBkTxKLZGx5TGhvj5O2G0SRWNoz/78nu9wcxkFMGNg6quQqL6RA&#xA;0s5Y6ir5vt9lD1JwBDIwOMJKHpH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AAJQB&#xA;AAALAAAAAAAAAAAAAAAAAC8BAABfcmVscy8ucmVsc1BLAQItABQABgAIAAAAIQB6iRROswIAACAG&#xA;AAAOAAAAAAAAAAAAAAAAAC4CAABkcnMvZTJvRG9jLnhtbFBLAQItABQABgAIAAAAIQAw7yw64AAA&#xA;AAoBAAAPAAAAAAAAAAAAAAAAAA0FAABkcnMvZG93bnJldi54bWxQSwUGAAAAAAQABADzAAAAGgYA&#xA;AAAA&#xA;" fillcolor="#bf8f00 [2407]" strokecolor="#538135 [2409]" strokeweight="2.25pt">
                <v:stroke joinstyle="miter" endcap="square" />
                <v:textbox>
                    <w:txbxContent>
                        <w:p w:rsidR="00D10BFA" w:rsidRDefault="00D10BFA" w:rsidP="00D10BFA">
                            <w:pPr>
                                <w:jc w:val="center" />
                            </w:pPr>
                            <w:r>
                                <w:t>THEQUICKBROWNFOXJUMPSOVERTHELAZYDOG.THEQUICKBROWNFOXJUMPSOVERTHELAZYDOG.THEQUICKBROWFA</w:t>
                            </w:r>
                        </w:p>
                    </w:txbxContent>
                </v:textbox>
            </v:oval>
        </w:pict>
    </mc:Fallback>
</mc:AlternateContent>

It contains rPr and mc:AlternateContent. My problem here is that when I try to do r.getContent(), you would expect to have two elements rPr and mc:AlternateContent. But in actual result, you would only have pict, since the behavior goes like: r.getContent() only fetches elements inside the <mc:Fallback> tag.

What I want to have is, I want to retrieve <a:graphic> which is definitely inside <mc:Choice>.<w:drawing>.<wp:anchor>.

1 Answers1

1

In general, the presence of an mc element causes an UnmarshalException, since it is invalid content according to the schemas used in docx4j.

When that happens, docx4j pre-processes the content through org/docx4j/jaxb/mc-preprocessor.xslt which usually selects the mc:Fallback content.

You have various options to override this behaviour:

  • easy: you can supply your own xslt, which does something different; see the property "docx4j.jaxb.JaxbValidationEventHandler" to point to its location
  • more complex and completely unsupported: alter the XSDs to allow mc namespace content in the element of interest, then regenerate the relevant classes using xsd
  • modify a jaxb implementation itself, to cope with how the markup compatibility mechanism works. This would be very cool!

For more, Google 'office openxml markup compatibility and extensibility' or try this TC45 final draft.

JasonPlutext
  • 15,352
  • 4
  • 44
  • 84
  • Thanks for the lightning fast reply. Is it possible to just add LOC(s) in order to fetch **mc:Choice**? Because what if I want to get back to fetching **mc:Fallback** again? or what if I want to fetch both **mc:Choice** and **mc:Fallback**? – sorryiamnaive Feb 18 '15 at 06:25
  • Well, you can express logic in the XSLT. But the XSLT approach should only ever give you the contents of one of the choice or fallback elements. If you want to be able to access the mc:AlternateContent elements and its contents, add an @XmlElementRef for org.docx4j.mce.AlternateContent to org.docx4j.wml.R's field List content. You'll also need to add "org.docx4j.mce" to Context.jc. After doing that, you'll have what you ask, but I expect the content of those elements will be returned as XML (which you could unmarshal, of course) – JasonPlutext Feb 18 '15 at 07:15