OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

relax-ng message

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [Elist Home]


Subject: Re: Issue: redefinition without the original



Probably your algorithm needs one little twist.


Consider this.

A.rng
<grammar>
  <include href="B.rng">
    <define name="foo"/>  --- redefine
  </include>
</grammar>

B.rng
<grammar>
  <include href="C.rng">
    <define name="foo"/> --- redefine it once more.
  </include>
</grammar>

C.rng
<grammar>
  <!-- forget to define foo -->
</grammar>

Your algorithm cannot detect that C.rng has to define "foo". The fix
would be:


> When you see an <include>, first process the <define>s inside it; if the
> current value of the redefinition field is a), process the definition
> normally, add the definition to a temporary list associated with this
> include, and set the redefinition flag to b).

Use the following algorithm instead:

for( each <define> in <include>) {
  if( the current value of the redefinition field is (a) ) {
    process the definition normally.
  } else {
    ignore the definition (actually, it has to be parsed to detect the
    error, but the resulting pattern has to be ignored.)
  }
  
  add the definition to the "redefined-patterns" list.
  store the current value of the redefinition field
  change the redefinition field to (a).
}

(after processing the included grammar),
> Then run over the temporary list; if there are any definitions with the
> redefinition field equal to b), given an error.  In any case, change the
> redefinition field back to a).

We can't blindly change the redefinition field back to (a), because this
grammar may be included by another grammar and that grammar may
also be redefining the same pattern.

So, we change the redefinition field according to its original value.

If the original value of the field is (a), then set it (a).
If it is (b) or (c), then set it (c).

--
Kohsuke KAWAGUCHI                          +1 650 786 0721
Sun Microsystems                   kohsuke.kawaguchi@sun.com



[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [Elist Home]


Powered by eList eXpress LLC