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: repeating and recursive inclusion


Hi,

For my next challenge, I've been working on a RELAX NG schema for
XHTML. I thought it was a good target for checking out the modularity
capabilities - how easy would it be to split up a RELAX NG schema
along the same lines as the XHTML Modularisation effort, and pick and
choose bits from XHTML to incorporate into other namespaces.

I have two problems, which are both to do with include: repeated
includes and recursive includes through nested grammars.  Neither of
these is mentioned in the tutorial, so I'm going on Jing's behaviour
to work out what's allowed and what isn't.

The first problem is that if you include something twice then you run
into problems with having multiple defines of the same name. This is a
problem when you have a schema made up of several components, many of
which include the same file. For example, if both my inlphras.rng and
my hypertext.rng schema include attrib.rng (so that they can both be
used standalone), and then I include them both in xhtml.rng, I get
errors with Jing because the two copies of all the define elements in
attrib.rng get included.

I think that it would be a lot more useful if either:

  * you ignore subsequent inclusions of the same schema
  * you change the semantics of include to something similar to
    'import' in XSLT (which would mean that define/start within an
    include would no longer be necessary)

If you go with the first, by the way, I think it would be useful to
include in the tutorial something that demonstrated how to include
another schema and override its start, i.e.:

<include href="another.rng">
   <start combine="choice">
      <notAllowed />
   </start>
</include>

You don't need to use this if you're including only one schema (then
you can just put the new start within the include element), but you do
if you're including more than one schema that specifies its own start
element.

The second problem is to do with recursive inclusions in nested
grammars. I'm coming across this with client-side image maps - the map
element can have any block content (a Block.mix pattern), and within
it any a elements can have two extra attributes (shape and coords) to
indicate areas on the image that they correspond to.

What I really want to do is to be able to specify the content of the
map element by including all the definitions from the XHTML schema,
but redefining the a element.  I thought that something like:

   <element name="map">
      ...
      <grammar>
         <include href="xhtml.rng">
            <start>
               <ref name="Block.mix" />
            </start>
            <define name="a">
               <element name="a">
                  <ref name="Shape.attrib" />
                  ...
               </element>
            </define>
         </include>
      </grammar>
      ...
   </element>

would work, but Jing complains about recursive inclusion of the
csismap.rng file that the above pattern resides in (which is included
into the xhtml.rng file).

The above is closely tied to the exclusion problem that I gather
(from the issues list) that you're discussing.  If the above syntax
were allowed, I could prohibit a elements from the content of an a
element with:

   <element name="a">
      ...
      <grammar>
         <include href="xhtml.rng">
            <start>
               <ref name="Inline.mix" />
            </start>
            <define name="a">
               <notAllowed />
            </define>
         </include>
      </grammar>
      ...
   </element>

If the nested grammar is the wrong place for this, I wonder about
doing something like allowing ref elements to have define elements
nested within them, the semantic being that the current grammar is
used with the defines in the content being overridden.  In the two
examples above, this would look like:

   <element name="map">
      ...
      <ref name="Block.mix">
         <define name="a">
            <element name="a">
               <ref name="Shape.attrib" />
               ...
            </element>
         </define>
      </ref>
      ...
   </element>

   <element name="a">
      ...
      <ref name="Inline.mix">
         <define name="a">
            <notAllowed />
         </define>
      </ref>
      ...
   </element>

(If nested grammars *are* the right place, then the above would still
be handy in allowing you to reference the current grammar in all its
glory, rather than hard-coding the name of the file the grammar
resides in.  For example, if someone else added something to
Inline.mix in their schema, it's the new definition that I'd want to
be able to use rather than the one in xhtml.rng)
   
I could well be missing some other way of tackling this problem, and
I'd be very grateful for tips if I am. Or I might be way over the
80/20 line, or asking for something unimplementable, in which case I
apologise.
   
Cheers,

Jeni
---
Jeni Tennison
http://www.jenitennison.com/



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


Powered by eList eXpress LLC