[relaxng-user] line terminator in compact syntax
James Clark
jjc at jclark.com
Sun Dec 7 01:12:10 ICT 2003
On Sat, 2003-12-06 at 21:36, David Tolpin wrote:
> [The specification] explicitly distinguishes between
> the newline marker and \x{A},
Right.
> and says that both newline markers and \x{A}
> can be present in the stream after newline normalization.
Right.
> The grammar, further,
> mentions newline marker separate from \x{A}; and I understand it is that the newline
> marker is not any character but a special entry in the source stream.
Right. Newline markers get introduced by newline normalization.
> The grammar lists both &newline; and &#A; as line terminators. They are
> separate in the grammar, and I understand that these are two different things.
> Am I wrong?
They are different things.
> I would understand, if neither \x{A} nor \x{D} were line terminators or spaces, but
> rather normal characters, disallowed everywhere but in literals. I just don't understand
> the difference between xA and xD with regard to the language of the specification.
Let me try again. The fact that \x{A} is a line terminator means I can
write
## foo
## bar
equivalently as
## foo\x{A}##bar
Now consider
x = """foo
bar"""
This is equivalent to
x = """foo\x{A}bar"
regardless of whether the newline was represented as #xA, #xD or #xD #xA
in the input file. It is never equivalent to
x """foo\x{D}bar"""
Thus if for some reason my input schema must be a single line, the fact
that \x{A} is treated is a line terminator is sufficient to allow this.
I can turn my multi-line schema into a single-line schema by replacing
each newline terminator by \x{A}. Allowing \x{D} as a line-terminator
would not help, because transforming a schema by mapping a #xD into
\x{D} sometimes changes the meaning of the schema (i.e. when the #xD is
in a multiline string).
James
More information about the relaxng-user
mailing list