I would like to clear up the SQL-2 syntax for names and paths. From the JCR 2.0 spec:
Name ::= '[' quotedName ']' | '[' simpleName ']' | simpleName
quotedName ::= /* A JCR Name */
simpleName ::= /* A JCR Name that is also a legal SQL identifier */
Path ::= '[' quotedPath ']' | '[' simplePath ']' | simplePath
quotedPath ::= /* A JCR Path that contains non-SQL-legal characters */
simplePath ::= /* A JCR Name that contains only SQL-legal characters */
See the SQL:92 rules for <regular identifier> (in ISO/IEC 9075:1992 §5.2 <token> and <separator>).
I guess (not sure) that "quotedName" / "quotedPath" does not actually mean a name or path surrounded with single quotes, that means it wouldn't be the idea that the path /test/node can be surrounded in single quotes as in ['/test/node']. I guess the idea is to support bracketed identifiers that are delimited by brackets ([ ]) as in MS SQL Server:
That would mean spaces and special characters are preserved bracketed using [ ].
Not fully clear is how the characters [ and ] should be handled within bracketed identifiers. MS SQL Server requires doubling ] (so that [Employee]]] is the quoted version of Employee] ). That would mean a path test/node would result in [test]/node] (where [ is not doubled, only ]).