Page 1 of 1

<w:sdt> in <w:tr>

PostPosted: Fri Dec 17, 2010 9:27 am
by don_bm
I have a docx file that I'm recursively traversing but it seems to not be able to find any <w:sdt> nodes that are immediate children of <w:tr> nodes. The XML in question is:

Code: Select all
<w:tr w:rsidR="00AA41E9" w:rsidTr="00F878C1">
   <w:trPr>
      <w:trHeight w:val="1134"/>
   </w:trPr>
   <w:sdt>
      <w:sdtPr>
         <w:rPr>
            <w:rFonts w:cstheme="minorHAnsi"/>
            <w:color w:val="262626" w:themeColor="text1" w:themeTint="D9"/>
            <w:sz w:val="24"/>
            <w:szCs w:val="24"/>
         </w:rPr>
         <w:alias w:val="body text"/>
         <w:tag w:val="body text tag"/>
         <w:id w:val="18840786"/>
         <w:lock w:val="sdtLocked"/>
         <w:placeholder>
            <w:docPart w:val="2F1DC445ACB14427BC44DC52DC2EB9DD"/>
         </w:placeholder>
         <w:showingPlcHdr/>
      </w:sdtPr>
      <w:sdtContent>
         <w:tc>
            <w:tcPr>
....


And I'm getting the <w:tr> node's children with the following code:

Code: Select all
childElements = ((Tr) element).getEGContentCellContent();


but my childElements list doesn't have the <w:sdt> node in it. I'm pretty new to this so can anyone help me see what the issue is here?

Re: <w:sdt> in <w:tr>

PostPosted: Fri Dec 17, 2010 10:04 am
by jason
It should have org.docx4j.wml.CTSdtCell in it, or one of those wrapped in a javax.xml.bind.JAXBElement, in which case the CTSdtCell is (CTSdtCell) ((JAXBElement)o).getValue();

hope this helps .. Jason

Re: <w:sdt> in <w:tr>

PostPosted: Wed Dec 22, 2010 8:30 am
by don_bm
Thanks Jason, that did help! I wasn't aware that the <w:sdt> tag is the an CTSdtCell object. I figured the CTSdtCell was a <w:tc>. Thanks again for the assistance.