1 Reply Latest reply on Sep 7, 2010 1:17 PM by Randall Hauch

    How to escape the full stop in JCR Xpath query

    Szymon Brandys Newbie

      My configuration is ModeShape 2.2.0 with the filesystem connector running on Tomcat. I want to access file and folder nodes using JCR XPath. How should I access them, if they have full stop characters in their names.

        • 1. Re: How to escape the full stop in JCR Xpath query
          Randall Hauch Master

          The '.' character is allowed in XML names, so it does not need to be escaped. See the XML specification for details.

           

          But for future reference, the rules for escaping names of nodes, properties, node types, etc., in XPath are described in Section 6.6.4.9 of the JCR 1.0 specification:

           

          The names of elements and attributes (corresponding to nodes and properties, respectively) within an XPath statement must correspond to the form in which they (notionally) appear in the document view. This means that spaces (and any other non-XML characters) within names must be encoded according to the rules described in 6.4.3 Escaping of Names.

           

          The values of attributes, on the other hand, are not escaped in the XPath usage of document view (as opposed to the export usage, see 6.4.2.5 Multi-value Properties, 6.4.4 Escaping of Values and 6.6.4.10 Searching Multi-value Properties). ...

           

          Section 6.4.3 basically talks about how to escape any characters that are not allowed in XML names.

           

          Using XPath was defined in JCR 1.0, but deprecated in JCR 2.0, so the 2.0 specification does not talk in particular about escaping names in XPath. However, JCR 2.0's Section 7.4 does correspond to JCR 1.0's Section 6.4.3.