logo       

Re: [xmlc] getElementsByTagName in XHTML ?: msg#00004

java.enhydra.xmlc

Subject: Re: [xmlc] getElementsByTagName in XHTML ?

At 11:27 PM 8/11/2005 +0200, you wrote:
>Jacob Kjome pí¹e v Pá 05. 08. 2005 v 10:46 -0500:
>
>> > Well, even if the getElementsByTagName was supposed to start from
>> > children of the supplied node instead from the node itself then it still
>> > doesn't work as I tested that case as well.
>
>> What's the test case?
>
>I don't have one. It just happened to me in my project and I had to
>solve it immediately so I worked around it by implementing my own
>function but I also thought it was worth to post about that issue to the
>list. I helped to fix some bugs this way so I wanted to repeat it :-)
>

I guess I'm still unclear on the results, though. I suspected that you were mistakenly reporting this because you had stated that you expected the results to be children of the current tag, plus the current tag itself. That's clearly wrong. It should only be the children. So, you say you tested this? What were your results? More below...

>> If you were to do node.getElementsByTagName("td") and the
>> current node is a "td", I wouldn't expect to have any results returned unless
>> you were using nested tables.
>
>well of course I did node.getParentNode().getElementsByTagName("td").

Which, again, unless you were using nested tables, would return an empty node list so it would be pretty pointless to do.

> Or
>actually I did search for some other elements, perhaps <input> or
>something like that inside of <td>'s.
>

Now you are speculating, though. If it were true that you always got an empty node list, then you are saying that getElementsByTagName() simply never works. I'd be hard pressed to believe this without some real proof. This is something that we'd be getting complaints about constantly if it were true, which is why I remain skeptical.


>> If you are using the HTML DOM, that should be
>> node.getElementsByTagName("TD") anyway, since the HTML DOM stores its
>nodes in
>> upper case.
>
>I tried both "td" and "TD", don't worry :-)
>

Ok, but I still think you may have been expecting something that shouldn't have happened anyway.

>> > It's easy to write an implementation of getElementsByTagName that works
>> > correctly and I am just doing that but I still wonder why the supplied
>> > DOM method doesn't do what I'd expect.
>
>> I wonder if your expectation is valid?
>
>what's invalid on expecting the getElementsByTagName to return some
>elements?
>

<td>
<input ...>
</td>

td.getElementByTagName("td") should return an empty nodelist. It would be "invalid" to expect anything else. td.getElementsByTagName("input") should return a list with a single element of type HTMLInputElement. If this is not the case, there are serious problems in the Xerces which I've never run into.

>> I also wonder if your test is valid.
>
>I can't be 100% sure that my test was valid but I wrote my own function
>that does what I thought the getElementsByTagName would do - and it does
>it well with the same input parameters.
>

But you had previously said that you expected the current element to be returned in the node list along with other mistaken assumptions. So, I suspect that your version of getElementsByTagName() simply returned the current node along with any child nodes, guaranteeing at least one result ever time. If that's the behavior you want, then its a pretty useful utility function for you. But that doesn't make what element.getElementsByTagName() does, per the DOM spec, wrong.... unless there truly is a bug, which is unlikely.

>> Can you provide the testcase you mention above so that we can verify whether
>> there really is something wrong here?
>
>When I get some free time then perhaps yes. Sorry not now as I am too
>busy with the project :-| BTW, the HTML was already changed and I don't
>use the function anymore so creating a test case would require some
>work.
>

I hope you do get some free time because I'd love to see the case where getElementsByTagName() fails. It would be pretty important to get a fix in before the next release of XMLC. I hope you don't get the impression that I'm just blowing you off. But as Carl Sagan said many times, "Extraordinary claims require extraordinary evidence". I'm certainly willing to evaluate the evidence when it is provided, but find it hard to believe until then.

Jake

>Petr



--
You receive this message as a subscriber of the xmlc@xxxxxxxxxxxxx mailing list.
To unsubscribe: mailto:xmlc-unsubscribe@xxxxxxxxxxxxx
For general help: mailto:sympa@xxxxxxxxxxxxx?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise