Hello, "xmlns:" is not regular attribute, it is namespace definition. Instead of "addAttribute" method use QNames and "addNamespace()" methods.
final String XSI_NAMESPACE = "http://..."; final String ROOT_NAMESPACE = "http://..."; Element root = documentFactory.createElement("rootelement", ROOT_NAMESPACE); root.addNamespace("xsi", XSI_NAMESPACE); root.addAttribute(QName.get("schemaLocation", "xsi", XSI_NAMESPACE), "http://..."); root.addElement("child", ROOT_NAMESPACE) Sincerely, Filip Jirsák 2009/2/25 Christian-Josef Schrattenthaler <hotl...@software-agentur.com>: > Hi! > > > > I have to use xml files for a little Java project. These files are generated > over the Java application itself, but I have to use an external xml schema. > > > > The root element must look like: > > > > <rootelement xmlns=http://... xmlns:xsi=http://... > xsi:schemaLocation="http://..."> > > > > I did this over the .addAttribute Method, and it seems to work, but now I > get an empty xmlns attribute (xmlns=““) on each element I add to the xml > document. > > > > This generates an error, while validating the xml file against the external > xml schema. > > > > I tried also .addElement(„elementname“, „“) but this doesn’t work. A > parameter Namespace.NO_NAMESPACE is not allowed. > > > > I googled fort he problem, and I saw, that I am not alone with this problem, > but I dind’t find a solution (e.g. > http://sourceforge.net/tracker/index.php?func=detail&aid=1256551&group_id=16035&atid=116035). > > > > Greetings, > > Christian. > > ------------------------------------------------------------------------------ > Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA > -OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise > -Strategies to boost innovation and cut costs with open source participation > -Receive a $600 discount off the registration fee with the source code: SFAD > http://p.sf.net/sfu/XcvMzF8H > _______________________________________________ > dom4j-user mailing list > dom4j-user@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/dom4j-user > > -- Filip Jirsák fi...@jirsak.org ------------------------------------------------------------------------------ Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA -OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise -Strategies to boost innovation and cut costs with open source participation -Receive a $600 discount off the registration fee with the source code: SFAD http://p.sf.net/sfu/XcvMzF8H _______________________________________________ dom4j-user mailing list dom4j-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/dom4j-user