Changes to org.apache.xerces.dom.DocumentImpl in Enhydra 5.0

Marco Leal <[email protected]> Mon, 20 Oct 2003 15:21:26 +0100
Newsgroups gmane.comp.java.enhydra.general
Organization MobiComp
Message-ID <[email protected]>
Hi,

I stumbled upon a problem on Enhydra 5.0 that didn't exist in Enhydra
3.1. I was trying to make a wireless app use only URL encoding for
session maintenance instead of cookies by setting
"SessionManager.EncodeUrlState" to "Always". It didn't work at all for
WML documents although it worked perfectly for HTML.

I dug deep into the Enhydra source and came up with this:

1. The problem occurred in org.enhydra.xml.io.BaseDOMFormatter in the
constructor BaseDOMFormatter(Node node, OutputOptions outputOptions,
boolean forPreFormatting, String defaultEncoding, boolean[]
entityQuickCheck).

fDocument = DOMOps.getDocument(node);
[...]
// Setup URL rewriting, which needs DocumentInfo
fDocInfo = findDocumentInfo(fDocument);
fURLRewriter = (fDocInfo != null) ? fOptions.getURLRewriter() : null;

The URLRewriter always ended up null because fDocInfo was null.

2. The findDocumentInfo(Document document) method executes this code:

if (document instanceof DocumentInfo) {
	return (DocumentInfo)document;
} else if (document instanceof XMLObjectLink) {
	// Go back to the XMLObject if possible.
	return (DocumentInfo)((XMLObjectLink)document).getXMLObject();
} else {
	return null;
}

In (1.) the getDocument(Node node) method returns a
org.enhydra.wireless.wml.dom.xerces.WMLDocumentImpl object (which
extends org.apache.xerces.dom.DocumentImpl) for both Enhydra 3.1 and
Enhydra 5.0.
The difference is that in Enhydra 3.1 the DocumentImpl class implemented 
the org.enhydra.xml.xmlc.XMLObjectLink interface for XMLC support and
you'd get an non null object in (2.). This problem also occurs with 
XHTML documents.

A solution for this problem could be making the 
org.enhydra.wireless.wml.dom.xerces.WMLDocumentImpl and 
org.enhydra.xml.xhtml.dom.xerces.XHTMLDocumentBase implement the 
XMLObjectLink interface.

I'm not familiar with the XMLC/Xerces architecture so I'm not sure the 
impacts that this solution can have.

Any comments?

Marco.

-- 
Marco Leal
MobiComp - Mobile Computing & Wireless Solutions
http://www.mobicomp.com/

"Create like a god, command like a king, work like a slave." - Guy Kawasaki