Zeus: Possible bug?
"Daniel Livesay" <[email protected]> Mon, 30 Sep 2002 16:09:16 -0700
| Newsgroups | gmane.comp.java.enhydra.zeus |
|---|---|
| Message-ID | <005801c268d6$67561520$2a45fea9@mammoth> |
This is a multi-part message in MIME format.
------=_NextPart_000_0055_01C2689B.BA1E4240
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
I just started using the Zeus project, and ran a across a problem that =
might be a bug. I wanted to get the input of other users before posting =
a bug report.=20
Here is an example:
From the DTD used to generate classes:
<!ELEMENT DefaultLanguage EMPTY>
<!ATTLIST DefaultLanguage=20
xml:lang NMTOKEN 'en'>
Notice how the attribute name already has the namespace prefix in it =
because DTDs do not support namespaces.
Here is a portion of the generated startElement method in the =
DefaultLanguageImpl class:
for (int i=3D0, len=3Datts.getLength(); i<len; i++) {
String attName =3D atts.getLocalName(i);
String attValue =3D atts.getValue(i);
if (attName.equals("xml:lang")) {
setXmlLang(attValue);
}
}
As a result, the output XML after marshalling will not have the xml:lang =
attribute and its value because the inside of the if block will not be =
reached. This happens because the atts.getLocalName(i) will return lang =
because it does not return the namespace prefix, while atts.getQName(i) =
will return xml:lang. If the line String attName =3D =
atts.getLocalName(i); is changed to String attName =3D =
atts.getQName(i);, then the if statement will correctly evaluated to =
true and the attribute value can be set correctly and output during =
marshalling.
I wanted to get others' input because, like I said before, I am new to =
Zeus and I may be overlooking something. I apologize if this is out of =
the scope of this mailing list. Let me know what you think.
Dan
------=_NextPart_000_0055_01C2689B.BA1E4240
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.2800.1106" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>I just started using the Zeus project, =
and ran a=20
across a problem that might be a bug. I wanted to get the input of =
other=20
users before posting a bug report. </FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=3DArial size=3D2>Here is an example:</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>From the DTD used to generate=20
classes:</FONT></DIV><FONT face=3DArial size=3D2><!ELEMENT =
DefaultLanguage=20
EMPTY><BR><!ATTLIST DefaultLanguage=20
<BR> xml:lang NMTOKEN =
'en'></FONT>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>Notice how the attribute name already =
has the=20
namespace prefix in it because DTDs do not support =
namespaces.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>Here is a portion of the generated =
startElement=20
method in the DefaultLanguageImpl class:</FONT></DIV>
<DIV><FONT face=3DArial=20
size=3D2><BR> =
=20
for (int i=3D0, len=3Datts.getLength(); i<len; i++)=20
{<BR> &n=
bsp; =20
String attName =3D atts.getLocalName(i);</FONT></DIV>
<DIV><FONT face=3DArial=20
size=3D2> &nbs=
p; =20
String attValue =3D=20
atts.getValue(i);<BR> &nbs=
p; =20
if (attName.equals("xml:lang"))=20
{<BR> &n=
bsp; =20
setXmlLang(attValue);<BR> =
=20
}<BR> =20
}</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>As a result, the output XML after =
marshalling will=20
not have the xml:lang attribute and its value because the inside of the =
if block=20
will not be reached. This happens because the=20
<STRONG>atts.getLocalName(i)</STRONG> will return <STRONG>lang</STRONG> =
because=20
it does not return the namespace prefix, while =
<STRONG>atts.getQName(i)</STRONG>=20
will return <STRONG>xml:lang.</STRONG> If the line =
<STRONG>String=20
attName =3D atts.getLocalName(i);</STRONG> is changed =
to <STRONG>String=20
attName =3D atts.getQName(i);,</STRONG> then the if statement will =
correctly=20
evaluated to true and the attribute value can be set correctly and =
output during=20
marshalling.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>I wanted to get others' input because, =
like I said=20
before, I am new to Zeus and I may be overlooking something. I =
apologize=20
if this is out of the scope of this mailing list. Let me know =
what=20
you think.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>Dan</FONT></DIV></BODY></HTML>
------=_NextPart_000_0055_01C2689B.BA1E4240--