← Prev in month ← Prev in thread

[relax-ng] Issue: literal newlines in strings

From
James Clark <>
Date
2002-04-09T05:27:08+00:00
ID
004901c1df86$b527ca20$
Thread
[relax-ng] Issue: literal newlines in strings
The compact syntax currently allows newlines in strings.  For example,

"ab
cd"

is legal and is equivalent to "ab\x{A}cd" (assuming we accept the \x
proposal).

Many modern programming languages don't allow literal newlines in strings.
For example, in Java, you cannot write

"ab
cd"

Rather you have to write "ab\ncd".  One reason is to support better error
reporting/recoovery.  If you allow literal newlines in string literals, then
a missing closing delimiter may only be detected many lines further on.
Another reason is that allowing newlines in strings makes it harder to do
provide editing support: you can't detect whether a particular point is in a
string without parsing from the beginning of the document.

I'm not sure whether this is sufficient justification to prohibit literal
newlines in strings, but I think it's worth considering.

Note that if we did prohibit them, the parsing phase that handles \x escapes
would need to generate not simply a sequence of Unicode characters, but
rather a sequence of Unicode characters and line terminators.  (This is easy
to implement, since the line terminator can be represented internally by one
of the Unicode code points that XML disallows.)

James
← Prev in month ← Prev in thread