Skip to main content
sandhyab4212
Known Participant
January 20, 2025
Solved

DOCX from Dynamic Template issue

Hello,

I'm trying to generate document from XML code, I'm able to get the expected data if the data was single dictionary, but i have a requirement to generate document for a list of data items.

I have already seen many of the community posts, I followed the same pattern to generate doc using xml code, but I'm getting an error, says that syntax error in template.

Please let me know what i have done wrong here.

ERROR: Syntax error in template "fr.opensagres.xdocreport.document.docx.DocxReport@3ad77c4f!word/document.xml" in line 4, column 1468:
Encountered "\" \\b @before-row</w:t></w:r><w:r><w:rPr><w:noProof/></w:rPr><w:t>${d.@name}</w:t></w:r><w:r><w:rPr><w:noProof/></w:rPr><w:t>[/#list] \\b @after-row</w:t></w:r></w:p></w:tc><w:tc><w:tcPr><w:tcW w:w=\"", but was expecting pattern:
<ID>

I have shared the XML code and the template as well.


a!localVariables(
  local!data: {
    {
      name: "Sam",
      branch: "CSE",
      rollNum: "12301"
    },
    {
      name: "John",
      branch: "ECE",
      rollNum: "12302"
    }
  },
  concat(
    "",
    a!forEach(
      items: local!data,
      expression: ""
    ),
    ""
  )
)
[View:/cfs-file/__key/communityserver-discussions-components-files/11/test-doc_5F00_v2.docx:320:240]

Thank you

    davidj137213
    Brainy
    January 20, 2025

    Aren't you missing a  closing "]" in the expression used in the template?

    @before-row«[#list doc.info.rowvalues as»«${d.@name}»@after-row«[/#list]»

    4 replies

    davidj137213
    Brainy
    January 20, 2025

    Aren't you missing a  closing "]" in the expression used in the template?

    @before-row«[#list doc.info.rowvalues as»«${d.@name}»@after-row«[/#list]»

    sandhyab4212
    Known Participant
    January 21, 2025

    No, i didn't miss it, i have attached the template if you are willing to see, you can see

    davidj137213
    Brainy
    January 21, 2025

    I checked it in the template attached... Could you please check it again?