to do so, I have the fo" /> to do so, I have the fo" /> to do so, I have the fo"/>

How to escape colon in the attribute key with Thymeleaf

41 Views Asked by At

I want to generate the following entry in .xml file with Thymeleaf

<postalCode xsi:type="extPL:adxp.postalCode"> </postalCode>

to do so, I have the following template:

<postalCode th:attr="xsi:type='extPL:adxp.postalCode' </postalCode>

but the phrase xsi:type contains colon which breaks the syntax of the expression. How can I escape the colon to make it work? I tried various approaches with substituting &#58; for colon or &quot; for ', but nothing worked for me.

1

There are 1 best solutions below

1
Easterwood On BEST ANSWER

You could use single quotes ' to mask the colon like so

<postalCode th:attr="'xsi:type'='extPL:adxp.postalCode' </postalCode>

or the whole attribute argument

<postalCode th:attr="'xsi:type=extPL:adxp.postalCode'" </postalCode>