Skip to content

Word Text extraction fails to get nested content #163

Description

@LCV57

When attempting to extract text content from a word .docx document with a document.xml that looks like this:

<w:document..>
    <w:body>
        <!-- Modified by docx4j 8.3.1 (Apache licensed) using REFERENCE JAXB in Eclipse Adoptium Java 17.0.7 on Windows Server 2022 -->
        <w:p w:rsidR="005C4CF0" w:rsidP="005C4CF0" w14:paraId="78C54BDB" w14:textId="77777777">
            <w:r>
                <w:t>Im</w:t>
            </w:r>
            <w:r>
                <w:t xml:space="preserve"> going to add some basic information that comes from the clause:</w:t>
            </w:r>
        </w:p>
        <w:p w:rsidR="005C4CF0" w:rsidP="005C4CF0" w14:paraId="4241C94B" w14:textId="77777777"/>
        <w:sdt>
            <w:sdtPr>
                <w:alias w:val="Standard :  LC Simple Clause"/>
                <w:tag w:val="CLS_171644_182392_1329803"/>
                <w:id w:val="849765303"/>
                <w:richText/>
            </w:sdtPr>
            <w:sdtContent>
                <w:p w:rsidR="005C4CF0" w14:paraId="6751289D" w14:textId="22A85AC8">
                    <w:r>
                        <w:t xml:space="preserve">This is a simple clause, for contract:</w:t>
                    </w:r>
                    <w:sdt>
                        <w:sdtPr>
                            <w:alias w:val="Contract Name"/>
                            <w:tag w:val="ContractMgmt_ContractName"/>
                            <w:id w:val="-1113981428"/>
                            <w:dataBinding w:prefixMappings="xmlns:sqph='http://schemas.sciquest.com/tcm/office/placeholders/v1'" w:xpath="/sqph:contractplaceholders[1]/sqph:ContractMgmt_ContractName[1]" w:storeItemID="{F2499371-A9EB-4C98-8057-F42491D7ED37}"/>
                            <w:text/>
                        </w:sdtPr>
                        <w:sdtContent>
                            <w:r>
                                <w:t>LC Chat 04</w:t>
                            </w:r>
                        </w:sdtContent>
                    </w:sdt>
                </w:sdtContent>
            </w:sdt>
            <w:r>
            <w:t xml:space="preserve"> with contract number</w:t>
            </w:r>
            <w:sdt>
                <w:sdtPr>
                    <w:alias w:val="Work Group"/>
                    <w:tag w:val="ContractConfigSection_ContractProject"/>
                    <w:id w:val="-261304195"/>
                    <w:dataBinding w:prefixMappings="xmlns:sqph='http://schemas.sciquest.com/tcm/office/placeholders/v1'" w:xpath="/sqph:contractplaceholders[1]/sqph:ContractConfigSection_ContractProject[1]" w:storeItemID="{F2499371-A9EB-4C98-8057-F42491D7ED37}"/>
                    <w:text/>
                </w:sdtPr>
                <w:sdtContent>
                    <w:r>
                        <w:t>TCMTEST</w:t>
                    </w:r>
                </w:sdtContent>
            </w:sdt>
        </w:p>
    </w:body>
</w:document>

As the result, im getting text that is missing some of the content, specifically the content from sdtPr that are nested inside another sdtPr, in the example above would be the sdtPr with alias "Contract Name" that is inside sdtPr with alias "Standard : LC Simple Clause". Basically my result would look like this:

"Im going to add some basic information that comes from the clause
This is a simple clause, for contract: with contract number TCMTEST"

Where the text content "LC Chat 04" is missing, its suppoused to go after "for contract:".

Is there something i can do to improve this extraction?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions