Hi, The message below is a thread from a problem I am having that I posted to the Xindice (dbXML) mail list. The problem actually has more to do with Jaxen and JDOM so I think it would be helpful to discuss it here.
Sorry, I would have liked to include the stack trace for you here, but the restart on JBoss truncates the log. In any case, what is the Jaxen policy of compatibility with JDOM? Are you waiting for the next stable release or is the Jaxen CVS code tracking the JDOM code? Truly too many moving targets these days. Cheerio, Joel -------- Original Message -------- Subject: Re: Namespace blues Date: Wed, 12 Dec 2001 11:54:21 +0000 From: Joel Rosi-Schwartz <[EMAIL PROTECTED]> Reply-To: [EMAIL PROTECTED],[EMAIL PROTECTED] Organization: Techne Research Limited To: [EMAIL PROTECTED] References: <[EMAIL PROTECTED]> Okay, a decent night sleep usually helps ;-) Your suggestion makes perfect sense except that with JDOM it is not possible, as far as I know, to retrieve the SAX parser class from the SAXHandler class and there are no arrangements made to set parser features via the SAXHandler class. In the JDOM 1.0b7, the release I am using, it is not even possible to set the features via the SAXBuilder. I did find out from the JDOM mailing list this morning that in the current CVS code setFeatures is exposed via SAXBuilder. For the hell of it I gave the current JDOM code a try, but it broke other working Jaxen code. Thanks again for your help. Cheerio, Joel Tom Bradford wrote: > On Tuesday, December 11, 2001, at 03:05 PM, Joel Rosi-Schwartz wrote: > > It turns out that the following code was the cause of the problem: > > > > XMLResource resource = getDocumentResouce(pk); > > SAXHandler handler = new SAXHandler(); > > resource.getContentAsSAX(handler); > > document = handler.getDocument(); > > > > When I change it to the following all is fine: > > > > SAXBuilder builder = new SAXBuilder(false); > > document = builder.build(new StringReader((String) > > resource.getContent())); > > > > So, a couple of questions: > > > > 1. How much of a performance penalty will I be paying with this kludge? > > 2. Any ideas of why this happening? Is it likely to be a problem with > > JDOM, SAX or both? > > 3. Since I am inside of JBoss, I am a little leery of experimenting > > with the SAX libraries, it is already a bit of a nightmare with > > everyone more or less depending on their preferred parser. Sigh... > > This is similar to a problem that I recently fixed in Xindice. There > are SAX features for dealing with Namespaces. Some SAX parsers (like > Xerces) will not enable them by default, while others (like Crimson) > will. Normally, when a document is parsed, it will report the > namespaces to the handler (DOM, JDOM, whatever), but not the attributes > that declare the namespaces. On first parse, using namespace will > typically work, but if you serialize your object image to disk, you may > (and usually) do lose your declaring attributes. In order to ensure > that the namespace attributes are reported by SAX to the handler, call > this code before actually parsing the document: > > reader.setFeature("http://xml.org/sax/features/namespaces", true); > > reader.setFeature("http://xml.org/sax/features/namespace-prefixes", > true); > > This will force the SAX parser to report namespace attributes as well as > namespace URIs. > > -- > Tom Bradford - http://www.tbradford.org > Developer - Apache Xindice (formerly dbXML) > Maintainer - jEdit-Syntax Java Editing Bean _______________________________________________ Jaxen-interest mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/jaxen-interest