TO:vcvj
createElementNamespace是哪个类的函数啊??
我在JDOM的类里没有找到。
createElementNamespace是哪个类的函数啊??
我在JDOM的类里没有找到。
解决方案 »
- Hibernate中多对多的中间表问题(用注解)
- java菜鸟的问题,如何获取相对路径
- 求解一B/S项目中打印问题,急!!!!!
- 如何使用eclipse而不是myeclipse开发web项目并将其关联到tomcat
- java是否还会开源
- java设计题,高手帮忙看一下,谢了
- 调查一下啊^_^
- 什么时候用ejb才是效率最高的?
- strut2使用HttpServletResponse线程安全问题
- 对于大型的全省集成社区项目,Grails框架适合么
- 在struts中,采用什么样的方式可以控制如果用户没有登陆的话,系统就转到一个指定的登陆页面上呢?
- jboss自带的TOMCAT下,servlet应该在哪个XML文件里注册?格式如何?
VCVJ
怎么解决?多指教!
用Dom4J就解决了。
真的无法解决吗?
我觉得不太可能,一个还算比较成熟的JDOM,
这个都无法解决?
我想是否我们还没有真正理解JDOM啊?
首先声明我没有试过,不过公司一个同事试过了。
建议DOM4J试试,这个就没有必要多花时间了,另JDOM也不过是1.0。
很感谢!呵呵
不过她的解决方法我看不懂,你看看吧。
> Hi!
>
> We are four students from Norway. We are working on a project where we are
> translating xml to a java-system, and vice versa.Hey there. Hope it's going well.> We got this error when compiling our code:
>
> org.jdom.IllegalNameException: The name "dc:Description" is not legal for
> JDOM/XML elements: Element names cannot contain colons.
>
> Our DTD requires use of colons.( i.e <dc:Description>)
>
> we wonder if you could help us solving this problemHmmm... the XML 1.0 specification states that colons may be later used in
another specification, and that occurs in the XML Namespaces specification.
Because of that, JDOM assumes that if it sees a colon, it's used in a
namespace and things start to break down.One way to work around it, and maybe even bring your docs into
namespace-awareness, is to define a namespace and associate it with the dc
prefix:<root xmlns:dc="http://www.foo.com">Then you could just deal with elements by their local name (Description) and
the namespace URI (http://www.foo.com)I'm wondering, and copying the JDOM list, if there should be any way to turn
this off, as some people have your use-case.
Can an element or attribute name contain a colon?The XML 1.0 specification specifically reserves the colon character for use with XML Namespaces. No other use is compliant with XML 1.0. Therefore JDOM does not allow you to create element and attribute names that contain colons except when using namespaces. Furthermore, because of the way namespaces are implemented in JDOM, you cannot simply create an Element or Attribute with a fully qualified name like svg:title. That is you cannot do this:Element e = new Element("svg:title");Instead you must split the two parts into a Namespace and a local name. This is the proper JDOM way to create an element in a namespace:Element e =
new Element("title", "svg", "http://www.w3.org/2000/svg");The first argument is the local name. The second argument is the prefix. The third argument is the namespace URI.If you're trying to create the xml:lang and xml:space attributes use:Element e =
new Element("lang", Namespace.XML_NAMESPACE);
<?xml version="1.0" encoding="UTF-8"?>
<svg:title xmlns:svg="http://www.w3.org/2000/svg" />
你很热心!非常感谢!
对我有启发!