- From: Liam R E Quin <liam@w3.org>
- Date: Sat, 15 Sep 2012 02:44:40 -0400
- To: public-microxml@w3.org
I experimented with making an XSLT 1.0 stylesheet that takes an Automatic Namespaces / Unobtrusive Namespaces "namespace definition" and an XML instance (basically microxml except that XSLT can't really handle microxml as currently defined) and adds the namespaces in so you can use regular XML processing. You can get it from http://words.fromoldbooks.org/xml/microxml/ if you want; there's a simple and inadequate HTML 5 namespace definition file and a sample xhtml-without-namespaces file. The stylesheet would need a lot of work before production use, but right now, microbe.xsl takes an optional parameter, nsduri, which can be given a URL pointing to an "nsd" resource; if omitted, microbe looks for an ns="..." attribute on the top level element of its input, and, if that is not persent, falls back to looking for default.nsd in the same place as the microbe stylesheet (probably should try relative to the XML document first, but doesn't). The nsd file looks like this: <nsd> <title>HTML 5 Namespace Definition</title> <start> <ns>http://www.w3.org/1999/xhtml</ns> </start> <element match="html"> <ns>http://www.w3.org/1999/xhtml</ns> </element> <element match="math"> <ns>http://www.w3.org/1998/Math/MathML</ns> </element> </nsd> The title is ignored; right now so is "start". The match expressions must be simple names and currently do not nest. For example, if you run microbe.xsl with this example nsd file and an XLM document containing html and svg elements, the html elements end up declaring a default namespace of http://www.w3.org/1999/xhtml and the svg elements end up declaring a default namespace of http://www.w3.org/1999/xhtml - and no-one uses MathML, right, David? :-) :-) Todo: * process include elements in the nsd file * support attributes * look for nsd files in the right place It's XSLT 1 so that it could be used in a Web browser. Liam -- Liam Quin - XML Activity Lead, W3C, http://www.w3.org/People/Quin/ Pictures from old books: http://fromoldbooks.org/ Ankh: irc.sorcery.net irc.gnome.org freenode/#xml Co-author, 5th edition of "Beginning XML", Wrox, July 2012
Received on Saturday, 15 September 2012 06:45:14 UTC