From: Danny A. <dan...@vi...> - 2003-03-07 01:09:34
|
> > "Using JAXP to both read and write an XML document" > > Yes, but it's also not as pretty or as elegant as EXML's. Prettiness and elegance would be relatively low on my priority list, but that's just a personal thing. > Oh, no. Actually, the namespacing in JAXP is *predeterminate* where > namespacing in XML is not. Consider RDF. Here's the "normal" declaration: > > <rdf:RDF > xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" > xmlns:dc="http://purl.org/dc/elements/1.1/" > xmlns="http://purl.org/rss/1.0/" > > ... > > Now, consider this EQUALLY VALID declaration: > > <foo:RDF > xmlns:foo="http://www.w3.org/1999/02/22-rdf-syntax-ns#" > xmlns:dc="http://purl.org/dc/elements/1.1/" > xmlns="http://purl.org/rss/1.0/" > > > > JAXP does not support this. The namespace prefix is really just an artifact of the serialization, so it'll depend on what's being used there. I'm pretty sure that whether an implementation extension (like those in Xerces) or a blank transform is used, this kind of namespace support will be available. In JAXP, you have to search for the actual > name of the element, including namespace, so you have to search for > "rdf:RDF" and not "namespace locally referred to as rdf" and "RDF", the > way EXML does it. The second decl should work in EXML. It has no chance in > JAXP. The element is disambiguated by the combination of the namespace and the local name, so these will need specifying somewhere whatever you do. I honestly can't see much advantage in searching for one string ('rdf') over another ('http://www.w3.org/1999/02/22-rdf-syntax-ns#') - it'll normally be held in a variable either way. If you really wanted to you could write a couple of convenience methods. The reason I have chosen JAXP (well, Xerces usually) over alternatives in the past is because of the existing user base, and for a lot of people it's a known quantity. I personally think this outweighs elegance. It took me half an hour to even find a page about EXML - the Eiffel parser is better known. Anyhow, there's my couple of centissimi. Cheers, Danny. |