Hi Kohei,
Yes this is possible in Relax NG (and XSD). You may want to have a look
at Murata et al. (2005) for some of the background if you are interested
in how the schema languages compare in expressiveness...
Here is a little example on how this can be done specifically in Relax
NG. Consider the following document should be rendered invalid:
So, what we want to express is that "a" may not contain "z" if it occurs
as a child "b". A Relax NG grammar to say so can be written as follows
(I apologize for the size of the example. I'm no good at Relax NG
compact syntax):
References:
Murata, M., Lee, D., Mani, M., and Kawaguchi, K. (2005) 'Taxonomy of XML
schema languages using formal language theory'. In: ACM Trans. Inter.
Tech. 5, 4 (Nov. 2005), 660-704. DOI=
http://doi.acm.org/10.1145/1111627.1111631
(alternative link:
http://www.cobase.cs.ucla.edu/tech-docs/dongwon/mura0619.pdf)
Kohei Yoshida wrote:
> Hi Lars,
>
> On Tue, 2007-08-14 at 11:57 +0200, Lars Oppermann wrote:
>
>> There are, as you should be aware of, technical possibilities of
>> constraining the schema as to disallow certain contents in certain
>> elements depending on their context. This was not possible when the
>> schema was still specified in a DTD.
>
> (Please bear with me if this is a basic question as I'm certainly not an
> XML schema expert.)
>
> So, do I read from your above statement that, now that we are using
> Relax NG as the schema language, it is now possible to constrain or
> specify different sets of legal child elements of *the same element*
> depending on the context? (it would be great if it is.)
>
> If yes, then I think we should work toward making it explicit in the
> spec in some way. Because in reality, the exact meaning and behavior of
> table cells is unfortunately different between word processor and
> spreadsheet apps, the spec IMHO should reflect this and be explicit
> about this in text.
>
> Even if it's 'no', then we should still put some note about possibly
> different interpretation of the legality of the child elements of
>