How can I leverage String constants in an XML file?

Posted by jayshao on Stack Overflow See other posts from Stack Overflow or by jayshao
Published on 2010-04-02T21:01:02Z Indexed on 2010/04/02 21:03 UTC
Read the original article Hit count: 229

Filed under:
|
|
|

I'd like to enforce standardized keys by storing them as static final String variables on a Java class, and either referencing or statically importing them, to use them as values in either XML, Strings, Methods, Annotations, etc.

Does anyone know a good way to have Maven insert (like filtering) values like StringKeys.SOME_KEY into an XML file? e.g. something like

<element value="${StringKeys.SOME_KEY}"/>

or similar - the main idea is to enforce commonality and prevent key mis-alignment. Or an alternative solution to accomplish the same - with some semantic that if a non-existant String is referenced, that it fails during build? Bonus points if it works in C# as well.

© Stack Overflow or respective owner

Related posts about java

Related posts about maven-2