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

 


Help: OASIS Mailing Lists Help | MarkMail Help

relax-ng-comment message

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


Subject: Re: [relax-ng-comment] Element Content Dependent on Attribute *Value*?


James Clark scripsit:

> Is it possible to make element content dependent on the attribute value?

Yes, indeed.  In fact, it is possible to create schemas that work when
the element type is completely unknown, and the content model depends
solely on attribute values.  The following (preliminary) schema for
XLink, which depends on the presence and value of the xlink:type
attribute, illustrates the point.  This schema is valid RELAX NG,
compact syntax, but may contain semantic errors I haven't spotted yet.

=====cut here=====

datatypes xsd = "http://www.w3.org/2001/XMLSchema-datatypes";
namespace xlink = "http://www.w3.org/1999/xlink";

href = attribute xlink:href {xsd:anyURI}
role = attribute xlink:role {xsd:anyURI}
arcrole = attribute xlink:arcrole {xsd:anyURI}
title.att = attribute xlink:title {text}
show = attribute xlink:show {"new"|"replace"|"embed"|"other"|"none"}
actuate = attribute xlink:actuate {"onLoad"|"onRequest"|"other"|"none"}
label = attribute xlink:label {xsd:NMTOKEN}
from = attribute xlink:from {xsd:NMTOKEN}
to = attribute xlink:to {xsd:NMTOKEN}

simple = element * {
                attribute xlink:type {"simple"}, anyAttr*,
                href?, role?, arcrole?, title.att?, show?, actuate?,
                (anyElem | text)*
                }

extended = element * {
                attribute xlink:type {"extended"}, anyAttr*,
                role?, title.att?,
                (title | resource | locator | arc | anyElem | text)*
                }

title = element * {
                attribute xlink:type {"title"}, anyAttr*,
                (anyElem | text)*
                }

resource = element * {
                attribute xlink:type {"resource"}, anyAttr*,
                role?, title.att?, label?,
                (anyElem | text)*
                }

locator = element * {
                attribute xlink:type {"locator"}, anyAttr*,
                href, role?, title.att?, label?,
                (title | anyElem | text)*
                }

arc = element * {
                attribute xlink:type {"arc"}, anyAttr*,
                arcrole?, title.att?, show?, actuate?, from?, to?,
                (title | anyElem | text)*
                }

start = element * { anyAttr*, (simple | extended | anyElem)* }

anyElem = element * {anyAttr*, (anyElem | text)*}

anyAttr = attribute * - xlink:*  {text}

-- 
John Cowan <jcowan@reutershealth.com>     http://www.reutershealth.com
I amar prestar aen, han mathon ne nen,    http://www.ccil.org/~cowan
han mathon ne chae, a han noston ne 'wilith.  --Galadriel, _LOTR:FOTR_


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


Powered by eList eXpress LLC