enigma-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Enigma-devel] Create xml dom using java.


From: Erich Schubert
Subject: Re: [Enigma-devel] Create xml dom using java.
Date: Tue, 19 Jun 2012 09:38:23 +0200

Hello Reece,
You need to define the prefixes using the Namespace APIs.
Usually, they do not need to be "el:". It's up to the user to choose these prefixes.
The key part is to map the prefix to a namespace, there should be a xmlns:el attribute on an appropriate parent node.

Typical code looks (here: SVG, adding an xlink: namespace) like this:

root = document.getDocumentElement();
root.setAttribute(SVGConstants.XMLNS_PREFIX, SVGConstants.SVG_NAMESPACE_URI);
root.setAttributeNS(SVGConstants.XMLNS_NAMESPACE_URI, SVGConstants.XMLNS_PREFIX + ":" + SVGConstants.XLINK_PREFIX, SVGConstants.XLINK_NAMESPACE_URI);

using a namespaced attribute:
elem.setAttributeNS(SVGConstants.XLINK_NAMESPACE_URI, SVGConstants.XLINK_HREF_QNAME, value);

creating a namespaced element:
document.createElementNS(namespaceURI, qualifiedName);

qualifiedName here is prefix+":"+tag name
namespaceURI is the actual URI of the namespace. I guess the XML DOM factory will check the the namespace has been defined as above.

Regards,
Erich

reply via email to

[Prev in Thread] Current Thread [Next in Thread]