logo       

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

java.enhydra.general

Subject: Re: [xmlc] getElementsByTagName in XHTML ?

Quoting Petr Stehlik <pstehlik@xxxxxxxxxx>:

> Hi,
>
> node.getTagName() returns "td" because that node is of type
> HTMLTableCellElement...
>

You are using the HTML DOM or XHTML? From above, it looks like the HTML DOM as
the XHTML DOM would be XHTMLTableCellElement, no? Typo?

> The same node.getElementsByTagName("td") returns an empty NodeList while
> it should contain at least itself, IMHO. Therefore I'd say that the
> getElementsByTagName method doesn't work correctly (for XHTML only?).
>

Well, apparently for HTML DOM since it seems that is what you are using. In any
case, here's what the API says...

/**
* Returns a <code>NodeList</code> of all descendant <code>Elements</code>
* with a given tag name, in the order in which they are encountered in
* a preorder traversal of this <code>Element</code> tree.
* @param name The name of the tag to match on. The special value "*"
* matches all tags.
* @return A list of matching <code>Element</code> nodes.
*/
public NodeList getElementsByTagName(String name);

According to this, only descendents would be returned. I'd think it awefully
odd behavior that it would return itself. Was this just your opinion or based
on some other part of the spec that I am unaware of?

> 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? 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. If you are using the HTML DOM, that should be
node.getElementsByTagName("TD") anyway, since the HTML DOM stores its nodes in
upper case.

> 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? I also wonder if your test is valid.
Can you provide the testcase you mention above so that we can verify whether
there really is something wrong here?

Jake

> Enhydra XMLC version 2.2, Enhydra 5.1.15.
>
> Thanks.
>
> 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