Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8683729
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T22:07:19+00:00 2026-06-12T22:07:19+00:00

I’m building a small java program to test all the document related features i

  • 0

I’m building a small java program to test all the “document related” features i need to cover with docx4j to fulfill my project requirements. In abstract: being able to create templates with “content controls” that will be offered as “raw template” to the users. Let the user enhance them, to finally populate them with data. I’m dealing with “docx4j” because of the “repeating and conditional” features.

This has been my progress, programmatically:

1) Create a blank document (DONE)

2) Add a custom xml part with the xml data (the part3.xml in the invoice example). (DONE)

3) Add a custom xml part with the xml xpaths reference (the part4.xml in the invoice example). (DONE)

4) Add the content control (PENDING)

It has to be something similar to this extract from the invoice example:

<w:sdt>
  <w:sdtPr>
    <w:alias w:val="Customer name" />
    <w:tag w:val="od:xpath=x1&customer name=customer name" />
    <w:id w:val="1418037941" />
    <w:placeholder>
      <w:docPart w:val="DefaultPlaceholder_22675703" />
    </w:placeholder>
    <w:dataBinding w:xpath="/invoice[1]/customer[1]/name[1]" w:storeItemID="{8B049945-9DFE-4726-9DE9-CF5691E53858}" />
    <w:text />
  </w:sdtPr>
  <w:sdtContent>
    <w:p>
      <w:r>
        <w:t>Joe Bloggs</w:t>
     </w:r>
    </w:p>
  </w:sdtContent>
</w:sdt>

And here is my question: How to generate this xml ? Can be done by Java code or only from Word? What are and how are generated the “1418037941” and the “DefaultPlaceholder_22675703” values? I guess i cannot “invent” them, and are referenced somewhere else.
I was looking for some method in MainDocumentPart class to do so but was unable to find it.
Am i misunderstandig something?

The other steps are almost ok for me:

5) Perform “preprocess” (DONE)

6) Perform “process” (DONE)

7) Perform “strip” (DONE, except removing repat tags)

Thank you very much for your help!
David

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T22:07:21+00:00Added an answer on June 12, 2026 at 10:07 pm

    You can certainly create a content control programmatically using docx4j. That said, the usual approach for creating a “template” is to use an authoring tool, such as this one.

    To answer your specific questions:-

    • You can leave out the w:placeholder.

    • The spec says w:id is type xsd:int, being an integer between
      -2147483648 and 2147483647. You can generate it randomly, or you may be able to leave it out as well.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have thousands of HTML files to process using Groovy/Java and I need to
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I used javascript for loading a picture on my website depending on which small
In my XML file chapters tag has more chapter tag.i need to display chapters
We're building an app, our first using Rails 3, and we're having to build
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have an array which has BIG numbers and small numbers in it. I
I have a text area in my form which accepts all possible characters from
I need a function that will clean a strings' special characters. I do NOT

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.