Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to escape '&' in maven pom property values [duplicate]

Tags:

xml

maven

pom.xml

I need to set a URL via a maven property (to be replaced per profile). The problem is that this URL contains some & and maven doesn't like this (if URL contains &_program):

"The reference to entity "_program" must end with the ';' delimiter." error occurs in pom on this line.

So how to escape this character or how to escape a hole line that might contain some "special" characters. (What other characters are forbidden in property-values?)

like image 883
dermoritz Avatar asked Jan 02 '12 14:01

dermoritz


People also ask

How do you escape from family?

To disown your family as an adult, separate yourself from them by moving out or living with a friend if you're still living at home. You should also stop calling them or responding to their calls or emails. If they have your phone number or email address, change them so your family members can't reach you.


2 Answers

I've not used maven but from the sounds of it, standard XML escaping would get the job done. In your case you can try using

& instead of &

What characters do I need to escape in XML documents?

like image 98
mikey Avatar answered Oct 13 '22 09:10

mikey


You can escape one character or a whole line that might contain some "special" characters by surrounding property value with <![CDATA[ property value ]]>. For example for some URL it would look like:

<properties>
    <some.url><![CDATA[http://stackoverflow.com?param_1=1&param_2=2]]></some.url>
</properties>
like image 20
Tomasz Szymulewski Avatar answered Oct 13 '22 09:10

Tomasz Szymulewski