- From: Steven Pemberton <steven.pemberton@cwi.nl>
- Date: Tue, 18 Mar 2025 13:09:31 +0000
- To: public-ixml@w3.org
- Message-Id: <1742302765441.1695286011.4289168969@cwi.nl>
Bethan: One of the things I've been thinking about recently is that we have a bunch of dynamic errors that are things like there not being a single root node, or two attributes with the same name on the same element.
… Earlier the spec says that conformance is about processors and grammars, not the combination of a grammar and in input.
… That being the case, I think these should be static errors on the grammar; not errors that are only thrown if a particular input produces not-well formed XML.
… I'm convinced you can do it.
Real-life example: I have an input where repeatedly I get A, B and C, but not necessarily in that order.
I know the input is correct, so I write:
input: event*.
event: (A; B; C)+, #a.
@a: date.
@b: who.
@c: where.
date: ... etc
This grammar allows <event a="..." a="..."/>, but it will never happen because my input will never generate it.
If this were to be classed as a static error, then I would have to write:
input: event*.
event: (ABC; ACB; BAC; BCA; CAB; CBA), #a.
ABC: a, b, c.
ACB: a, c, b.
BAC: b, a, c.
BCA: b, c, a.
CAB: c, a, b.
CBA: c, b, a.
@a: date.
@b: who.
@c: where.
date: ... etc
which I would rather not have to do.
Steven
On Tuesday 18 March 2025 13:50:26 (+01:00), Steven Pemberton wrote:
Looks like you had a great discussion in the status reports section. Sorry I missed it.
Bethan says: "What I'm interested in working on are tools that will treat your grammar as a generator rather than a recognizer."
I've written several of these in the past (for instance, when I wrote a version of Eliza, the Rogerian psychotherapist, I wrote another program to generate random paranoid ramblings for Eliza to respond to (https://cwi.nl/~steven/Talks/2024/09-oxford/ai.html#L2734)
In fact, they are quite easy to write, since it is just a recursive random path through the grammar tree. This is the complete code, where 'thing' is either a terminal or nonterminal ('choice' returns a random element of a sequence, in this case returning a random alternative from a rule):
HOW TO GENERATE thing
FROM grammar:
SELECT:
nonterminal(thing):
FOR symbol
IN choice grammar[thing]:
GENERATE symbol FROM grammar
ELSE:
WRITE thing, "
"
And you generate one rambling with "GENERATE '<sentence>' FROM sentences"
Steven
On Tuesday 04 March 2025 16:42:47 (+01:00), Norm Tovey-Walsh wrote:
> Hi folks,
>
> Draft minutes are online:
>
> https://www.w3.org/2025/03/04-ixml-minutes.html
>
> Be seeing you,
> norm
>
> --
> Norm Tovey-Walsh
> Saxonica
>
>
Received on Tuesday, 18 March 2025 13:09:37 UTC