Created
June 5, 2013 08:08
-
-
Save suxiaogang/5712340 to your computer and use it in GitHub Desktop.
Set Namespace In JDom
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void write(Writer writer) throws Exception { | |
Element rootElement = new Element("ABC"); | |
namespace = Namespace.getNamespace("","http://abc.com/abc_1_0_0"); | |
rootElement.setNamespace(namespace); | |
rootElement.addNamespaceDeclaration(namespace); | |
Namespace ns = Namespace.getNamespace("xsi","http://www.w3.org/2001/XMLSchema-instance"); | |
rootElement.addNamespaceDeclaration(ns); | |
rootElement.setAttribute("schemaLocation", "http://abc.com/abc.xsd", ns); | |
this.writeDomain(rootElement); | |
Document document = new Document(rootElement); | |
DocumentHelper.write(document, writer); | |
namespace = rootElement.getNamespace(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment