- From: Janne Saarela <jsaarela@w3.org>
- Date: Tue, 08 Sep 1998 18:04:45 +0200
- To: xml-names-issues@w3.org
I wanted to report some experience I have had implementing the 2-Aug-98 version of the namespaces specification [1] within the SiRPAC [2] RDF compiler V1.4. First of all, SiRPAC uses the SAX interface to the XML document "stream". With each startElement I build up the document tree and while doing this, I use both an element and namespace stack. The former manages the element nesting level and the latter manages namespace declarations by using Hashtables for each new element level (even through there were no new namespace declarations). The hashtable is first built extracting necessary information from xmlns: attributes. Then, any element and attribute prefix is expanded by iterating through the namespace Hashtable stack to find the declaration from the prefix to a namespace URI. In this way, in the context of parsing RDF, both the element name and attribute names are expanded by simply concatenating the namespace URI and the element/attribute name. Thus, the application, once given the document tree, will not see the namespace prefixes at all. Implementing and testing all this took one day. (let's see how many bugs remain :-) BTW, in RDF it is beneficial to have a method getAttributeValue (Namespace, AttributeName) for an element. In this way, you can easily request, for example, the "about" attribute value from the namespace that interests you. Like in the following I do element.getAttributeValue(RDFSCHEMA, "about"); <RDF xmlns="http://www.w3.org/TR/WD-rdf-syntax#" xmlns:foo="foo#" xmlns:bar="bar#"> <Description about="http://some.org/some.doc" foo:about="rating1" bar:about="rating2" /> </RDF> Janne [1] http://www.w3.org/TR/1998/WD-xml-names-19980802 [2] http://www.w3.org/RDF/Implementations/SiRPAC/ -- Janne Saarela | Visiting scientist Email: jsaarela@w3.org | World Wide Web Consortium http://www.w3.org/
Received on Tuesday, 8 September 1998 12:04:23 UTC