Re: w3c html dom versioning oddities

Arno Schatz <[email protected]>
Newsgroups gmane.comp.java.enhydra.xmlc
Message-ID <[email protected]>
Hi Jake,

(first question already answered by Michael.)

Jacob Kjome wrote:
> A further question.  Since Xerces2 seems to be doing the "correct" thing 
> in distributing only the original html dom level1 standard interfaces 
> rather than the level2, it seems that consumers of the interfaces ought 
> to fall into line with the original standard, if possible.  To that end, 
> what is the appropriate change to make to the following code...
> 
> optionElement.setSelected(selectionModel.isSelectedIndex(i));
> 

You are using a serverside API. The 'setSelected'-method really makes only sense on the 
client (that mean in the browser). The 'setDefaultSelected' method is what you should 
use. That what I got out from reading the spec.
That being said, I know, that the 'setDefaultSelected' is not fully implemented in the 
Xerces HTML DOM Implementation (that's what the comments in the source code say.) I have 
tested it with xmlc and plain Xerces yesterday and it did not behave correctly.

I think this is a bug, which just hasn't been detected, since people just used 
'setSelected'. I will file a bug-report with a patch.

> 
> would it be?.....
> 
> if (selectionModel.isSelectedIndex(i)) 
> optionElement.setAttribute("selected", "selected");
> else optionElement.removeAttribute("selected");
> 

This is of course a good workaround, since it is the code being executed internally anyway.

> 
> Or is there another way?

I patched setDefaultSelected, if you are interested, I can send you the patch.

-Arno
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.