m goal is to use content controls to replace placeholders. Creating content is eay using word. next I have to figure out how to replace these content controls with actual data using docx4j.
the examples I saw ContentControlsMergeXML,ContentControlsXmlEdit
I want to follow ContentControlsXmlEdit
- Code: Select all
String inputfilepath = System.getProperty("user.dir") + "/sample-docs/word/databinding/binding-simple.docx";
// Load the Package
WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage.load(new java.io.File(inputfilepath));
// Get the part
// First we need to get the part. There are a few different ways to do this.
// If we know the itemId ..
String itemId = "{5448916C-134B-45E6-B8FE-88CC1FFC17C3}".toLowerCase();
CustomXmlDataStoragePart customXmlDataStoragePart = wordMLPackage.getCustomXmlDataStorageParts().get(itemId);
here in the above code I dont understand how to get the itemId? I checked the unzip verion of my document and its not present.
- Code: Select all
// .. if you don't know the itemId (which you can get using ContentControlsPartsInfo),
// you could get the part by name, by type,
// or you could find the item Id by looking in an SDT for w:storeItemID:
// <w:sdt>
// <w:sdtPr>
// <w:dataBinding w:prefixMappings="" w:xpath="/myxml[1]/element1[1]"
// w:storeItemID="{5448916C-134B-45E6-B8FE-88CC1FFC17C3}"/>
// </w:sdtPr>
// <w:sdtContent>
// Get the contents
(or you could find the item Id by looking in an SDT for w:storeItemID:) its not in the document.xml
so the second approach is to you could get the part by name, by type any examples on this?
all the core part of replacing lies in this
- Code: Select all
CustomXmlDataStorage customXmlDataStorage = customXmlDataStoragePart.getData();
((CustomXmlDataStorageImpl)customXmlDataStorage).setNodeValueAtXPath("/myxml/element1", example_value_to_inject,
"xmlns:ns0='http://your.namespace'");
but my problem is I dont know how to get customXmlDataStorage instance, as I dont know how to get CustomXmlDataStoragePart , please help me
here is my document.xml
- Code: Select all
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<w:document xmlns:ve="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:m="http://schemas.openxmlformats.org/officeDocument/2006/math" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:wp="http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing" xmlns:w10="urn:schemas-microsoft-com:office:word" xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main" xmlns:wne="http://schemas.microsoft.com/office/word/2006/wordml">
<w:body>
<w:p>
<w:pPr>
<w:pStyle w:val="SigBox"/>
<w:tabs>
<w:tab w:val="clear" w:pos="4320"/>
<w:tab w:val="clear" w:pos="8640"/>
</w:tabs>
<w:jc w:val="center"/>
<w:rPr>
<w:b/>
<w:szCs w:val="24"/>
<w:u w:val="single"/>
</w:rPr>
</w:pPr>
<w:r>
<w:rPr>
<w:b/>
<w:szCs w:val="24"/>
<w:u w:val="single"/>
</w:rPr>
<w:t>CERTIFIED MAIL - RETURN RECEIPT REQUESTED</w:t>
</w:r>
</w:p>
<w:sdt>
<w:sdtPr>
<w:rPr>
<w:szCs w:val="24"/>
</w:rPr>
<w:id w:val="-889017388"/>
<w:placeholder>
<w:docPart w:val="EDCA2E64CFCD4F488D76F03E8327CACD"/>
</w:placeholder>
<w:text/>
</w:sdtPr>
<w:sdtContent>
<w:p>
<w:pPr>
<w:pStyle w:val="SigBox"/>
<w:tabs>
<w:tab w:val="clear" w:pos="4320"/>
<w:tab w:val="clear" w:pos="8640"/>
</w:tabs>
<w:ind w:left="2880" w:firstLine="720"/>
<w:rPr>
<w:sz w:val="22"/>
<w:szCs w:val="22"/>
</w:rPr>
</w:pPr>
<w:r>
<w:rPr>
<w:sz w:val="22"/>
<w:szCs w:val="22"/>
</w:rPr>
<w:t xml:space="preserve"/>
</w:r>
<w:proofErr w:type="gramStart"/>
<w:r>
<w:rPr>
<w:sz w:val="22"/>
<w:szCs w:val="22"/>
</w:rPr>
<w:t>facIdentificationNumber</w:t>
</w:r>
<w:proofErr w:type="gramEnd"/>
</w:p>
</w:sdtContent>
</w:sdt>
<w:p>
<w:pPr>
<w:spacing w:after="0"/>
<w:rPr>
<w:rFonts w:ascii="Times New Roman" w:hAnsi="Times New Roman"/>
</w:rPr>
</w:pPr>
</w:p>
<w:p>
<w:pPr>
<w:spacing w:after="0"/>
<w:rPr>
<w:rFonts w:ascii="Times New Roman" w:hAnsi="Times New Roman"/>
<w:highlight w:val="yellow"/>
</w:rPr>
</w:pPr>
</w:p>
<w:sdt>
<w:sdtPr>
<w:rPr>
<w:rFonts w:ascii="Times New Roman" w:hAnsi="Times New Roman"/>
<w:b/>
</w:rPr>
<w:tag w:val="adl/transmittalLetterDate"/>
<w:id w:val="-885164104"/>
<w:placeholder>
<w:docPart w:val="EDCA2E64CFCD4F488D76F03E8327CACD"/>
</w:placeholder>
<w:text/>
</w:sdtPr>
<w:sdtContent>
<w:p>
<w:pPr>
<w:spacing w:after="0"/>
<w:rPr>
<w:rFonts w:ascii="Times New Roman" w:hAnsi="Times New Roman"/>
<w:b/>
</w:rPr>
</w:pPr>
<w:proofErr w:type="gramStart"/>
<w:r>
<w:rPr>
<w:rFonts w:ascii="Times New Roman" w:hAnsi="Times New Roman"/>
<w:b/>
</w:rPr>
<w:t>transmittalLetterDate</w:t>
</w:r>
<w:proofErr w:type="gramEnd"/>
</w:p>
</w:sdtContent>
</w:sdt>
<w:p>
<w:pPr>
<w:spacing w:after="0"/>
<w:rPr>
<w:rFonts w:ascii="Times New Roman" w:hAnsi="Times New Roman"/>
<w:highlight w:val="yellow"/>
</w:rPr>
</w:pPr>
</w:p>
<w:sdt>
<w:sdtPr>
<w:rPr>
<w:rFonts w:ascii="Times New Roman" w:hAnsi="Times New Roman"/>
</w:rPr>
<w:tag w:val="adl/granteeName"/>
<w:id w:val="-885164123"/>
<w:placeholder>
<w:docPart w:val="EDCA2E64CFCD4F488D76F03E8327CACD"/>
</w:placeholder>
<w:text/>
</w:sdtPr>
<w:sdtContent>
<w:p>
<w:pPr>
<w:spacing w:after="0"/>
<w:rPr>
<w:rFonts w:ascii="Times New Roman" w:hAnsi="Times New Roman"/>
</w:rPr>
</w:pPr>
<w:proofErr w:type="gramStart"/>
<w:r>
<w:rPr>
<w:rFonts w:ascii="Times New Roman" w:hAnsi="Times New Roman"/>
</w:rPr>
<w:t>granteeName</w:t>
</w:r>
<w:proofErr w:type="gramEnd"/>
</w:p>
</w:sdtContent>
</w:sdt>
<w:sdt>
<w:sdtPr>
<w:rPr>
<w:rFonts w:ascii="Times New Roman" w:hAnsi="Times New Roman"/>
</w:rPr>
<w:tag w:val="adl/granteeAddress"/>
<w:id w:val="-885164106"/>
<w:placeholder>
<w:docPart w:val="EDCA2E64CFCD4F488D76F03E8327CACD"/>
</w:placeholder>
<w:text/>
</w:sdtPr>
<w:sdtContent>
<w:p>
<w:pPr>
<w:spacing w:after="0"/>
<w:rPr>
<w:rFonts w:ascii="Times New Roman" w:hAnsi="Times New Roman"/>
</w:rPr>
</w:pPr>
<w:proofErr w:type="gramStart"/>
<w:r>
<w:rPr>
<w:rFonts w:ascii="Times New Roman" w:hAnsi="Times New Roman"/>
</w:rPr>
<w:t>granteeAddress</w:t>
</w:r>
<w:proofErr w:type="gramEnd"/>
</w:p>
</w:sdtContent>
</w:sdt>
<w:p>
<w:pPr>
<w:spacing w:after="0"/>
<w:rPr>
<w:rFonts w:ascii="Times New Roman" w:hAnsi="Times New Roman"/>
</w:rPr>
</w:pPr>
<w:r>
<w:rPr>
<w:rFonts w:ascii="Times New Roman" w:hAnsi="Times New Roman"/>
</w:rPr>
<w:t xml:space="preserve"/>
</w:r>
</w:p>
<w:p>
<w:pPr>
<w:spacing w:after="0"/>
<w:rPr>
<w:rFonts w:ascii="Times New Roman" w:hAnsi="Times New Roman"/>
</w:rPr>
</w:pPr>
</w:p>
<w:p>
<w:pPr>
<w:spacing w:after="0"/>
<w:ind w:left="720"/>
<w:rPr>
<w:rFonts w:ascii="Times New Roman" w:hAnsi="Times New Roman"/>
<w:noProof/>
</w:rPr>
</w:pPr>
<w:r>
<w:rPr>
<w:rFonts w:ascii="Times New Roman" w:hAnsi="Times New Roman"/>
<w:noProof/>
</w:rPr>
<w:t>In accordance with 45 CFR 98.66(f), you may request reconsideration by the Assistant Secretary. A request for reconsideration will not preclude your right to a subsequent appeal. Your written request for reconsideration by the Assistant Secretary must be made within 30 days of the date of this letter, and must include a copy of this disallowance letter, and be sent to:</w:t>
</w:r>
</w:p>
<w:p>
<w:pPr>
<w:spacing w:after="0"/>
<w:rPr>
<w:rFonts w:ascii="Times New Roman" w:hAnsi="Times New Roman"/>
</w:rPr>
</w:pPr>
</w:p>
<w:p>
<w:pPr>
<w:spacing w:after="0"/>
<w:rPr>
<w:rFonts w:ascii="Times New Roman" w:hAnsi="Times New Roman"/>
</w:rPr>
</w:pPr>
</w:p>
<w:p>
<w:pPr>
<w:spacing w:after="0"/>
<w:ind w:left="720"/>
<w:rPr>
<w:rFonts w:ascii="Times New Roman" w:hAnsi="Times New Roman"/>
<w:noProof/>
</w:rPr>
</w:pPr>
<w:r>
<w:rPr>
<w:rFonts w:ascii="Times New Roman" w:hAnsi="Times New Roman"/>
<w:noProof/>
</w:rPr>
<w:t>In accordance with 45 CFR 98.66(f), you may request reconsideration by the Assistant Secretary. A request for reconsideration will not preclude your right to a subsequent appeal. Your written request for reconsideration by the Assistant Secretary must be made within 30 days of the date of this letter, and must include a copy of this disallowance letter, and be sent to:</w:t>
</w:r>
</w:p>
<w:p>
<w:pPr>
<w:spacing w:after="0"/>
<w:rPr>
<w:rFonts w:ascii="Times New Roman" w:hAnsi="Times New Roman"/>
</w:rPr>
</w:pPr>
</w:p>
<w:p>
<w:pPr>
<w:spacing w:after="0"/>
<w:rPr>
<w:rFonts w:ascii="Times New Roman" w:hAnsi="Times New Roman"/>
</w:rPr>
</w:pPr>
</w:p>
<w:p>
<w:pPr>
<w:spacing w:after="0"/>
<w:rPr>
<w:rFonts w:ascii="Times New Roman" w:hAnsi="Times New Roman"/>
</w:rPr>
</w:pPr>
</w:p>
<w:p>
<w:pPr>
<w:spacing w:after="0"/>
<w:ind w:left="720"/>
<w:rPr>
<w:rFonts w:ascii="Times New Roman" w:hAnsi="Times New Roman"/>
<w:noProof/>
</w:rPr>
</w:pPr>
<w:r>
<w:rPr>
<w:rFonts w:ascii="Times New Roman" w:hAnsi="Times New Roman"/>
<w:noProof/>
</w:rPr>
<w:t>In accordance with 45 CFR 98.66(f), you may request reconsideration by the Assistant Secretary. A request for reconsideration will not preclude your right to a subsequent appeal. Your written request for reconsideration by the Assistant Secretary must be made within 30 days of the date of this letter, and must include a copy of this disallowance letter, and be sent to:</w:t>
</w:r>
</w:p>
<w:p>
<w:pPr>
<w:spacing w:after="0"/>
<w:rPr>
<w:rFonts w:ascii="Times New Roman" w:hAnsi="Times New Roman"/>
</w:rPr>
</w:pPr>
</w:p>
<w:p/>
<w:sectPr>
<w:pgSz w:w="12240" w:h="15840"/>
<w:pgMar w:top="1440" w:right="1440" w:bottom="1440" w:left="1440" w:header="720" w:footer="720" w:gutter="0"/>
<w:cols w:space="720"/>
<w:docGrid w:linePitch="360"/>
</w:sectPr>
</w:body>
</w:document>