[relaxng-user] relaxng-driven editing

David Tolpin dvd at davidashen.net
Thu Oct 30 12:20:16 ICT 2003


> > However, for many practical cases, the set of valid elements at any given point is determined
> > by a small context of the point; for docbook, for example, it is one parent and one preceding
> > element for all cases. 
> > 
> > RELAX NG in general may require a wider context for this approach; due to its context-dependence.
> > Is there a known algorithm to build distinct lookback contexts?
> 
> I don't know of one, but I've never looked.  In nXML mode, I maintain
> state that allows me to incrementally compute validity.  This state also
> allows me to determine the derivative at any point, without having to
> figure out what part of the context is relevant.  There's a long comment
> at the beginning of the file rng-valid.el in the nXML mode distribution
> that explains my approach.

James,

thank you. I had read the comment and the source code of nXML (an
exciting experience indeed) before posting the comment. I am also
familiar with a similar technique because  it had been used in a
pascal interpreter for secondary schools in early 90s (a demo with
coloring of up-to-date areas was nice).

The problem -- my problem -- is that I am writing a program that needs to know

1) not just the set of first elements in a pattern, but a set of
all elements of particular kind (block-level text markup -- para,
title, term, listitem) which do not have the opening tag of a
preceding element in this pattern.

      <listitem>
    </itemizedlist>
    (<para>|<itemizedlist><listitem/>+</itemizedlist>)
  </section>*
  <section>
    <title>
    ...

should bring '(listitem para title).

This has roughly exponential time compared to the time to compute first elements.

2) other contexts where b indirectly follows a, to decide whether it is appropriate to
offer to close a group and/or open a new one.  This requires (or I just think so) 
analysis of the grammar, not just of the derivative.

I tried to compute the things dynamically, but my algorithm was not fast enough to use
interactively. I'll try again, or maybe it's just my slow notebook.

Thank you again,
David Tolpin


More information about the relaxng-user mailing list