Duplicate "xmlns" attributes

林 昌紀 <[email protected]>
Newsgroups gmane.text.xml.xalan.java.user
Message-ID <[email protected]>
Hello,

I encountered a suspicious phenomenon of Xalan-j 2.7.1.
When I parsed the XML below with Xalan-j 2.7.1, using getAttributes 
method of Node A, I got 2 "xmlns" attributes in the result.
There should be only 1 "xmlns" attribute in the result, I suppose.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE A [
	<!ATTLIST A xmlns CDATA #FIXED 'http://test.xmlns.com/test#'>
]>
<A>
  <A1>test</A1>
</A>

For example, if I build and run the attached program (Test.java), 
I get the result below. (2 xmlns attributes)

Attr 0:
 NodeName  = xmlns
 NodeValue = http://test.xmlns.com/test#
 NameSpace = http://www.w3.org/2000/xmlns/
Attr 1:
 NodeName  = xmlns
 NodeValue = http://test.xmlns.com/test#
 NameSpace = null

But expected result is:

Attr 0:
 NodeName  = xmlns
 NodeValue = http://test.xmlns.com/test#
 NameSpace = http://www.w3.org/2000/xmlns/

This problem occurred only when I use Xalan-j 2.7.1.
When I use Xalan-j 2.7.0, this problem never occurs.

Is there anyone who knows about this problem?
Is there any workaround?

I have attached the sample program and the XML file.
(Please add the path of xalan.jar(2.7.1) to CLASSPATH.)

My test environment is below:
  Java : jdk1.6.0 update 12
  Xalan: Xalan-j 2.7.1 (Xerces 2.9.0)
  OS   : Windows XP

Thanks,
Masanori Hayashi

---
Masanori Hayashi <[email protected]>
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.