Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TemplateProcessor::replaceBlock regular expression not matching #523

Open
skwi opened this issue Apr 17, 2015 · 5 comments
Open

TemplateProcessor::replaceBlock regular expression not matching #523

skwi opened this issue Apr 17, 2015 · 5 comments

Comments

@skwi
Copy link

skwi commented Apr 17, 2015

Hello,

I have a non matching case in TemplateProcessor::replaceBlock method regular expression.

In the template document I use, it does not match the tag.
Here is a sample of the document where you can see the tag.

<w:p w:rsidR="00D04554" w:rsidRDefault="00015D44" w:rsidP="00C57049"><w:pPr><w:jc w:val="both"/><w:rPr><w:rFonts w:ascii="Calibri" w:hAnsi="Calibri"/></w:rPr></w:pPr><w:r><w:rPr><w:rFonts w:ascii="Calibri" w:hAnsi="Calibri"/></w:rPr><w:t>${</w:t></w:r><w:r w:rsidR="00D04554" w:rsidRPr="00D04554"><w:rPr><w:rFonts w:ascii="Calibri" w:hAnsi="Calibri"/></w:rPr><w:t>ENSEMBLE_PERSONNEL</w:t></w:r><w:r w:rsidR="00A9712A"><w:rPr><w:rFonts w:ascii="Calibri" w:hAnsi="Calibri"/></w:rPr><w:t>}</w:t></w:r></w:p>

<w:p w:rsidR="00D04554" w:rsidRDefault="007227A3" w:rsidP="00C57049"><w:pPr><w:jc w:val="both"/><w:rPr><w:rFonts w:ascii="Calibri" w:hAnsi="Calibri"/></w:rPr></w:pPr><w:r w:rsidRPr="001A55F0"><w:rPr><w:rFonts w:ascii="Calibri" w:hAnsi="Calibri"/><w:i/></w:rPr><w:t>L</w:t></w:r><w:r w:rsidR="002C759B" w:rsidRPr="001A55F0"><w:rPr><w:rFonts w:ascii="Calibri" w:hAnsi="Calibri"/><w:i/></w:rPr><w:t>’ensemble d</w:t></w:r><w:r w:rsidR="001D4074" w:rsidRPr="001A55F0"><w:rPr><w:rFonts w:ascii="Calibri" w:hAnsi="Calibri"/><w:i/></w:rPr><w:t>u personnel</w:t></w:r><w:r w:rsidR="002C759B" w:rsidRPr="001A55F0"><w:rPr><w:rFonts w:ascii="Calibri" w:hAnsi="Calibri"/><w:i/></w:rPr><w:t xml:space="preserve"> salarié de la société</w:t></w:r><w:r w:rsidR="002C759B" w:rsidRPr="001A55F0"><w:rPr><w:rFonts w:ascii="Calibri" w:hAnsi="Calibri"/></w:rPr><w:t xml:space="preserve"> </w:t></w:r></w:p>

<w:p w:rsidR="007227A3" w:rsidRPr="001A55F0" w:rsidRDefault="00015D44" w:rsidP="00C57049"><w:pPr><w:jc w:val="both"/><w:rPr><w:rFonts w:ascii="Calibri" w:hAnsi="Calibri"/></w:rPr></w:pPr><w:r><w:rPr><w:rFonts w:ascii="Calibri" w:hAnsi="Calibri"/></w:rPr><w:t>${/</w:t></w:r><w:r w:rsidR="00D04554" w:rsidRPr="00D04554"><w:rPr><w:rFonts w:ascii="Calibri" w:hAnsi="Calibri"/></w:rPr><w:t>ENSEMBLE_PERSONNEL</w:t></w:r><w:r w:rsidR="00A9712A"><w:rPr><w:rFonts w:ascii="Calibri" w:hAnsi="Calibri"/></w:rPr><w:t>}</w:t></w:r></w:p>

The tag in the document is ${ENSEMBLE_PERSONNEL} [...] ${/ENSEMBLE_PERSONNEL}

I guess it's related to all the XML tags that Word inserted in the document but the template will be created by non technical users so I can tell them to fix it in the XML.


Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

@Cbruyere
Copy link

have you try to parse your xml online ?
http:https://www.freeformatter.com/xml-formatter.html
maybe it could be a helper :)

I've got : Unable to parse any XML input. org.jdom2.input.JDOMParseException: Error on line 1: The prefix "w" for element "w:p" is not bound.

@skwi
Copy link
Author

skwi commented Apr 17, 2015

The xml was generated by Office Word (and the file is properly opened, even after PHPWord manipulation) so I don't think it's badly formated.

w:p tags seems to be a valid OpenXML word, event if it's not valid in freeformater

@skwi
Copy link
Author

skwi commented Apr 22, 2015

I manage to make it work by removing the (<\?xml.*) part of the regex in the TemplateProcessor::replaceBlock method.

It looked like a line break at the beginning of the file made the regex fail. I edited the document with Word 12 on Mac OS 10.10, maybe that the reason for this failing line break.

I am going to work on a fork to se if I can come to a "clean" regex working with my document but keeping the (<\?xml.*).

@samdark
Copy link

samdark commented Jul 31, 2017

Duplicate of #316

@github-actions
Copy link

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
If this is still an issue for you, please try to help by debugging it further and sharing your results.
Thank you for your contributions.

@github-actions github-actions bot added the Stale label Nov 18, 2022
@Progi1984 Progi1984 removed the Stale label Nov 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

4 participants