Re: XLink 1.1, let's get the party started

Norman Walsh scripsit:

> Two new (non-normative) appendixes for W3C XML Schema and RELAX NG
> Grammars and minor editorial twiddles here and there.

One twiddle that isn't quite editorial that I'd like to see is
banning attributes from the XLink namespace that aren't defined in the
specification.  Currently, if such appear they are undefined.

Here's my RELAX NG grammar for documents containing XLinks that conform
to XLink 1.1, with the constraint I just mentioned.  I hope it will
be fairly readable even to people who aren't familiar with RELAX NG.
(Trang makes a complete hash of converting this to DTD or XML Schema,
because neither one can cope with any-named elements that are still
constrained by their attributes and content alone.)



namespace xlink = "http://www.w3.org/1999/xlink"

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

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

extended = element * {
		attribute xlink:type {"extended"},
		anyAttr*, role.att?, 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.att?, title.att?, label.att?,
		(anyElem | text)*
		}

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

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

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

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

anyAttr = attribute * - xlink:*  {text}



-- 
There are three kinds of people in the world:   John Cowan
those who can count,                            http://www.reutershealth.com
and those who can't.                            jcowan@reutershealth.com

Received on Wednesday, 24 November 2004 21:14:17 UTC