Reputation: 401
how do we escape xml element name in java
I am building xml with a run time data that have many special characters (e.g, "(") I know about StringEscapseUtils of apache-common-lang but it does not escape element name
any other option
Upvotes: 2
Views: 587
Reputation: 108859
I am building xml with a run time data that have many special characters (e.g, "(") I know about StringEscapseUtils of apache-common-lang but it does not escape element name
I don't think such an escape mechanism has been formalized. (
cannot be part of an element name. Here are the constraints for an element name:
Name ::= NameStartChar (NameChar)*
NameStartChar ::= ":" | [A-Z] | "_" | [a-z] | [#xC0-#xD6] | [#xD8-#xF6] |
[#xF8-#x2FF] | [#x370-#x37D] | [#x37F-#x1FFF] | [#x200C-#x200D]
| [#x2070-#x218F] | [#x2C00-#x2FEF] | [#x3001-#xD7FF] |
[#xF900-#xFDCF] | [#xFDF0-#xFFFD] | [#x10000-#xEFFFF]
NameChar ::= NameStartChar | "-" | "." | [0-9] | #xB7 | [#x0300-#x036F] |
[#x203F-#x2040]
Upvotes: 1