Java JCR is it possible to add '&' into node name

26 views Asked by At

If I'm renaming node in JCR, is it possible to add & to that name? Currently when I pass string name for ex: test & node it is saved as test---node./

1

There are 1 answers

1
Marcin Orlowski On

The naming restrictions are documented here:

The JCR specification already restricts what can go into the “local” part of an item name - see JCR v2.0 Specification, Section 3.2. In particular:

  • Characters not allowed in XML are forbidden in names as well; this affects most control characters plus unpaired surrogates; see Extensible Markup Language (XML) 1.0 (Fifth Edition), Section 2.2.
  • Furthermore, the names . and .. can not be used.
  • Finally, the characters /, :, [, ], |, and * are forbidden. For these, the JCR v2.0 Specification, Section 3.2.5.4 proposes a mapping to “private-use” code points.

so as & is XML special character is not allowed without prior escaping to the entity (&).