- From: Philip Taylor <pjt47@cam.ac.uk>
- Date: Thu, 03 Sep 2009 16:58:46 +0100
- To: Shane McCarron <shane@aptest.com>
- CC: HTML WG <public-html@w3.org>, RDFa Developers <public-rdf-in-xhtml-tf@w3.org>
Shane McCarron wrote: > [...] If you want to implement an RDFa > processor such that it is truly namespace aware, discovering the > namespace prefix mappings via [in-scope namespaces] property... you are > certainly free to do so. I have yet to find a DOM implementation I can > get to in Perl that makes this easy to do (my RDFa processor is written > in Perl). Does XML::LibXML's DOM not make it adequately easy? use XML::LibXML; my $p = new XML::LibXML; my $doc = $p->parse_string('<foo xmlns="http://www.w3.org/..."> <foo xmlns:ns="http://example.com"><foo/></foo></foo>'); for my $e ($doc->getElementsByTagName('foo')) { print "$e\n"; for my $ns ($e->getNamespaces) { print ' ', $ns->name, ' = ', $ns->value, "\n"; } print ' lookup(ns) = ', ($e->lookupNamespaceURI('ns') || ''), "\n"; } (Obviously this won't work if you're constructing a DOM from an HTML parser (rather than an XML parser), because the XML Namespaces spec doesn't apply to non-XML HTML at all. But when you're doing everything with real XML, the namespace mappings should all work easily, as far as I'm aware.) -- Philip Taylor pjt47@cam.ac.uk
Received on Thursday, 3 September 2009 15:59:31 UTC