TO:vcvj
createElementNamespace是哪个类的函数啊??
我在JDOM的类里没有找到。

解决方案 »

  1.   

    TO:
    VCVJ
    怎么解决?多指教!
      

  2.   

    JDOM是无法解决的,公司里同事曾经遇到过这个问题。
    用Dom4J就解决了。
      

  3.   

    TO:zzzle(Vincent)
    真的无法解决吗?
    我觉得不太可能,一个还算比较成熟的JDOM,
    这个都无法解决?
    我想是否我们还没有真正理解JDOM啊?
      

  4.   

    感觉jdom还有不少问题,我今天也遇上了一个关于number的bug……
      

  5.   

    To linyhe(he)
    首先声明我没有试过,不过公司一个同事试过了。
    建议DOM4J试试,这个就没有必要多花时间了,另JDOM也不过是1.0。
      

  6.   

    明天我下一个Dom4J帮你试吧,那个写起来很方便的。
      

  7.   

    TO:zzzle
    很感谢!呵呵 
      

  8.   

    帮你查了一下,证实JDOM无法解决这个问题。
    不过她的解决方法我看不懂,你看看吧。
    > 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.
      

  9.   

    JDOM官方解答:
    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);
      

  10.   

    结果是这样的
    <?xml version="1.0" encoding="UTF-8"?>
    <svg:title xmlns:svg="http://www.w3.org/2000/svg" />
      

  11.   

    TO:zzzle(Vincent)
    你很热心!非常感谢!
    对我有启发!