The mighty version attribute
Shaun McCance
<shaunm at gnome.org>
Sun Feb 20 18:51:57 EST 2011
- Previous message: The links element
- Sort by: [ thread ] [ subject ] [ author ] [ date ]
Hi folks, I've been thinking for a long time about adding a version attribute to Mallard. It seems easy enough, but I wanted to define it in a way that allowed validators to know how to validate a page. And I wanted that to include extensions. I thought I had a really great idea on how to do this, but then ran across the "name classes aren't patterns" limitation in RELAX NG: http://tech.groups.yahoo.com/group/rng-users/message/1214 Turns out, I still think I have a good way to do this, but it requires working around this limitation. I've just done a basic proof-of-concept implementation of this idea, and I'd like to share it and get feedback. We'd have a version attribute on the page element. This attribute takes a space-separated list, where the first element identifies the primary schema, and the others identify extension schemas. Version token are mapped to URIs of RNG files as follows: * If the token has a colon, it's taken to be an absolute URI. * If the token has a slash (a/b), then we construct this URI: http://projectmallard.org/a/b/a-b.rng * Otherwise, we construct the URI from the token v like this: http://projectmallard.org/v/mallard-v.rng Then we construct a new RNG file by slurping in the contents of each of these, copying the child elements of each grammar element, being careful not to screw up element definitions that rely on the default namespace. Except (and this is the workaround), we need to rewrite the bits that allow external namespace elements and attributes. So we collect a list of namespaces by looking at the ns attribute of the grammar element of each of the RNG files. Then, whenever we encounter anyName/except, we replace it with anyName except any of the collected namespaces, plus the local namespace. It's not nearly as complicated as it sounds. I've attached an XSLT file that takes a Mallard file and outputs an RNG file that will validate the page according to what I just outlined. I wish the name class hack weren't necessary, but it is. This technique works nicely with the ways Mallard allows external namespace extensions. -- Shaun -------------- next part -------------- A non-text attachment was scrubbed... Name: mal2rng.xsl Type: application/xslt+xml Size: 2977 bytes Desc: not available URL: <http://projectmallard.org/pipermail/mallard-list/attachments/20110220/295b3f1c/attachment.xsl>
- Previous message: The links element
- Sort by: [ thread ] [ subject ] [ author ] [ date ]
- More information on mallard-list