[xmlc] Re: Re: Re: Accessing the body in a Document
"Jacob Kjome" <[email protected]> Tue, 15 Jun 2010 14:26:51 -0500
| Newsgroups | gmane.comp.java.enhydra.xmlc |
|---|---|
| Message-ID | <[email protected]> |
This is a multi-part message in MIME format... ------------=_1276630015-5928-2118 Content-Type: text/plain;charset=utf-8;format="flowed" Content-Transfer-Encoding: quoted-printable Hi Franck, I wrote a bunch of stuff below, but just thought of one thing that might = be=20 pertinent, so look into this before reading more further below. Which parser are you using?=C2=A0 Are you using the XML or HTML parser?=C2= =A0 If HTML,=20 can you try using the XML parser?=C2=A0 Note that the HTML parser won't v= alidate=20 your markup and may (depending on bugs in NekoHTML) get confused by XHTML= =20 markup (regardless of whether it validates against the XML parser).=C2=A0= You can=20 also try updating to the latest version of NekoHTML[1].=C2=A0 Many bugs h= ave been=20 fixed in it since the version that shipped with XMLC-2.3.1. [1] http://nekohtml.sourceforge.net/changes.html Jake If you don't make headway after looking into the above question, then rea= d=20 more below.... Unfortunately, I'm unable to reproduce the issue.=C2=A0 I tried setting u= p a plain=20 old XMLC project using both the HTML and XHTML DOMs and was able to use=20 getNextSibling() to access the "body" node just fine. I presume you are using XMLC-2.3.1?=C2=A0 I tried both 2.3.1 and the late= st SVN=20 head.=C2=A0 In both cases, everything worked just fine. Note that I place xercesImpl-2.9.1.jar in CATALINA_HOME/lib and=20 xml-apis-1.3.04.jar in CATALINA_HOME/endorsed It's been a while since I looked at Barracuda, but I presume=20 view.getDocument() (when using XMLC) is returning the XMLObject subclass = that=20 represents your document.=C2=A0 It's actually a wrapper to the real docum= ent.=C2=A0=20 Using getOwnerDocument() on any child node would give you the real Docume= nt=20 object.=C2=A0 You can call xmlObject.getDocument() if the current node re= presents=20 the document itself (getOwnerDocument() returns null if the current node = is=20 the Document itself).=C2=A0 Or you can just use XMLCs utility class/metho= d=20 DOMOps.getDocument(Node) to avoid having to care about where if the hiera= rchy=20 you are. In any case, once you have the real owner document, you should just be de= aling=20 with the plain old Xerces DOM, not XMLC specifics, other than the XHTML=20 specific extension classes (akin to the HTML DOM).=C2=A0 That said, the X= HTML DOM=20 serves the same purpose as the HTML DOM.=C2=A0 It just provides an [X]HTM= L-specific=20 API, such as getBody().=C2=A0 All the core DOM implementation details are= left to=20 the base Xerces DOM.=C2=A0 It's worth some more investigation, but I can'= t think of=20 a way that issues with getNextSibling() could possibly be influenced by t= he=20 XHTML/HTML DOM subclasses? You might want to just ping the Xerces-user list.=C2=A0 Michael Glavassev= ich, the=20 lead for Xerces, is pretty responsive and can probably tell you if this i= s, or=20 has been, an issue with Xerces. On Tue, 15 Jun 2010 18:35:49 +0200 Franck Routier <[email protected]> wrote: > Hi Jake and thanks for your input, >=20 > - my jars seem to be ok (I have xerces 2.9.1 and xml-apis 1.3.04), > (although I cannot exclude a classpath problem, but I don't think there > is one). > - using html dom, I can access the body element just fine (but my main > project is using xhtml all over the place) > - using getElementsByTagNale("body") is not any more lucky (length =3D = 0). >=20 >=20 > In the object I get on view.getDocument(), I find an attribute called > fDocument, which is my XHTMLDocumentImpl. The Document contains a > docElement (XHTMLHtmlElementImpl), that contains a first child > (XHTMLHeadElementImpl), that has no sibling... >=20 > But the object that view.getDocument() returns also contains attributes > like $element_My_Id (I guess these are generated by xmlc, isn't it ?). > Those elements have a ownerDocument, which is fDocument. And some of > them have a ownerNode that happens to be a XHTMLBodyElementImpl, and > that XHTMLBodyElementImpl has the same ownerDocument... >=20 > So the document structure seems fine, there really must be a bug with > getNextSibling or something.I'm not sure out to replicate the problem > outside of my project... if I can do so, I'll post on xerces mailing > list. Else, I'll just suspend my work on the subject ad wait for xerces > 2.10.0. >=20 > Thanks >Franck >=20 >=20 >=20 > Le lundi 14 juin 2010 =C3=A0 10:52 -0500, Jacob Kjome a =C3=A9crit : >> Hi Franck, >>=20 >> That is strange. Do you experience the same issue when using the HTML= DOM=20 >> rather than the XHTML DOM? What happens if you use the HTML DOM inter= face=20 >> method HTMLDocument.getBody()? How about getElementsByTagName("body")= (try=20 >> with and without providing the XHTML namespace)? >>=20 >> Hmm... I just performed the following search... >> http://www.google.com/search?q=3Dchild.getNextSibling%28%29+incorrectl= y+returns+null >>=20 >> ...and the following results look a bit suspicious... >>=20 >> http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=3D6333993 >> http://code.google.com/p/android/issues/detail?id=3D779 >>=20 >> When you run your server, try placing xercesImpl-2.9.1.jar in the serv= er's=20 >> classpath and place the xml-apis.jar that ships with Xerces 2.9.1 in a= n=20 >> "endorsed" library directory. Do you get the same results? >>=20 >> Besides that, it could be related to a recently fixed bug in Xerces de= aling=20 >> with transferring deferred nodes when using adopNode() (or cloneNode()= ,=20 >>which=20 >> might produce similar behavior and which XMLC does whenever it serves = up a=20 >> copy of the DOM). You could try building from the latest Xerces sourc= e or=20 >> just wait until 2.10.0 is released, which should be any time now accor= ding=20 >>to=20 >> reports on the Xerces user list. >>=20 >> https://issues.apache.org/jira/browse/XERCESJ-1450 >>=20 >>=20 >> Jake >>=20 >> On Mon, 14 Jun 2010 11:54:29 +0200 >> Franck Routier <[email protected]> wrote: >> > Hi, >> >=20 >> > I am playing with components in Barracuda, that I'd like to render i= n >> > the body tag of the document (these are script components, currently >> > rendered in the head, but yslow and google speed suggest it might be >> > better to render some of them at the end of the document). >> >=20 >> > So, in my renderer, I access to the Document using the following cod= e : >> >=20 >> > Node node =3D view.getNode(); >> > Document doc =3D node.getOwnerDocument(); >> > Element elRoot =3D doc.getDocumentElement(); >> >=20 >> > So here, doc is an ....Impl generated by xmlc, and elRoot correspond= s to >> > the htlm tag (in my example I have a XHTMLHtmlElement). >> > Until now I'm fine. >> >=20 >> > Node child =3D elRoot.getFirstChild(); >> >=20 >> > --> child is of type HTMLHeadElement. Ok. >> >=20 >> > child =3D child.getNextSibling(); >> >=20 >> > --> child is null. Argh. >> >=20 >> > Is there an explaination why my document does not give me access to = the >> > body Node ? >> >=20 >> > Thanks in advance, >> >=20 >> >Franck >> >=20 >> >=20 >> >=20 >>=20 >> pi=C3=A8ce jointe document texte brut (message-footer.txt) >> -- >> You receive this message as a subscriber of the [email protected] mailing l= ist. >> To unsubscribe: mailto:[email protected] >> For general help: mailto:[email protected]?subject=3Dhelp >> OW2 mailing lists service home page: http://www.ow2.org/wws >=20 >=20 >=20 >=20 ------------=_1276630015-5928-2118 Content-Type: text/plain; charset="UTF-8"; name="message-footer.txt" Content-Disposition: inline; filename="message-footer.txt" Content-Transfer-Encoding: quoted-printable -- You receive this message as a subscriber of the [email protected] mailing list= . To unsubscribe: mailto:[email protected] For general help: mailto:[email protected]?subject=3Dhelp OW2 mailing lists service home page: http://www.ow2.org/wws ------------=_1276630015-5928-2118--