例如:
Element testElement = new Element("test");
testElement.setAttribute("xsi:type","IP_TTTTT");
则会报如下错误:
Exception in thread "AWT-EventQueue-0" org.jdom.IllegalNameException: The name "xsi:type" is not legal for JDOM/XML attributes: Attribute names cannot contain colons.
各位XDJM们有没有碰到过类似的问题,又如何解决?
还有,生成XML文件时,如在根节点中生成了命名空间,为什么子元素中有个xmlns=""的.如
<SCL xmlns="http://www.iec.ch/61850/2003/SCL" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.iec.ch/61850/2003/SCL SCL.xsd">
<Header xmlns="" id="xxxxxx" name="Name" version="1" revision="1" />
<Communication xmlns="">
......
</Communication >
</SCL>
------解决方案--------------------
转义一下吧