How are multiple paragraphs being created by the OOXML

Connor Shore 110 Reputation points
2025-09-25T13:45:54.05+00:00

Hi, I have a question about this document:
https://windwardstudios.box.com/s/7gomh2ugumj0per8z5e1cbzulwgbnt30

The result in the DOCX is 3 separate paragraphs with field codes, however when I look at the document.xml, all of the content is held within a single paragraph with multiple runs. How are the paragraphs/new-lines being created by the ooxml in this case? To my understanding I'm not seeing anything that would indicate that new paragraphs should be there.

Thanks in advance,

Connor

Microsoft 365 and Office | Open Specifications
Microsoft 365 and Office | Open Specifications
Technical documents for protocols, computer languages, standards support, and data portability. The goal with Open Specifications is to help developers open new opportunities to interoperate with Windows, SQL, Office, and SharePoint.
0 comments No comments
{count} votes

Answer accepted by question author
  1. Jack-Bu 5,405 Reputation points Microsoft External Staff Moderator
    2025-09-25T14:22:39.5333333+00:00

    Dear Connor Shore

    Thank you for reaching out to Microsoft Q&A, with your question about the DOCX output from our Windward template.

    To address your concern, you're correct that field codes (like SEQ for numbering) themselves don't create new paragraphs; they only substitute text within existing runs. However, in the rendered result DOCX showing 3 separate paragraphs, this is likely due to how our AutoTag engine processes loops in the template. Specifically:

    • In the original template, a single <w:p> (paragraph) might contain a <<forEach>> loop tag that spans multiple runs.
    • When the template is processed with data (e.g., a dataset with 3 items), the engine dynamically replicates the entire XML region, including inserting new <w:p> elements, for each iteration. This expands what appeared as one paragraph in the template into multiple distinct paragraphs in the output.

    If you're inspecting the result DOCX's document.xml (not the template), you should see exactly 3 <w:p> tags within the <w:body>, each containing its own set of runs and field codes. If it still looks like a single paragraph to you, it could be a viewing issue in your XML editor, try searching for <w:p> tags or using a tool like the Open XML SDK Productivity Tool for better visualization.

    For reference, here's a simplified example of what the output XML might look like after processing:

    <w:body>
      <w:p>  <!-- Paragraph 1 -->
        <w:r><w:t>Item 1 text</w:t></w:r>
        <w:r><w:fldChar w:fldCharType="begin"/></w:r>
        <w:r><w:instrText>SEQ mylist</w:instrText></w:r>
        <w:r><w:fldChar w:fldCharType="end"/></w:r>
      </w:p>
      <w:p>  <!-- Paragraph 2 -->
        <!-- Similar structure for Item 2 -->
      </w:p>
      <w:p>  <!-- Paragraph 3 -->
        <!-- Similar structure for Item 3 -->
      </w:p>
    </w:body> 
    

    If this doesn't match what you're seeing, could you share a snippet of the document.xml from the result file? I'd be happy assist further


    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread. 

    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. John Korchok 223K Reputation points Volunteer Moderator
    2025-09-25T14:56:34.25+00:00

    If you have not prettified the XML to make it human-readable, the XML will appear as one paragraph in a text editor.

    In the sample document at your link, there are multiple separate paragraphs, each starting with <w:p> and ending with </w:p>. In NotePad++, I used the XML Tools add-in with the Pretty Print command. I then see paragraph start tags at lines 4, 198, 208, 311, 323, 354, 365, 476, 489, and 597.

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.