Hi !
Here is my xml file:
---------------------------
<smil xmlns="http://www.w3.org/2001/SMIL20/Language">
<head>
</head>
</smil>
---------------------------
In my code, the variable "headElement" (of type org.dom4j.Element) points
to the <head> element of my xml file.
if I do "headElement.declaredNamespaces();", I get a list that contains one
org.dom4j.Namespace,
and this is the one declared in the <smil> element of my xml document.
(With prefix=="" and uri=="http://www.w3.org/2001/SMIL20/Language")
Now, I want to add the "xml:lang" attribute to headElement.
I first create a QName:
Namespace myNamespace = new Namespace("xml", "http://dummyURI.com");
QName myQName = new QName("lang", myNamespace, "xml:lang");
headElement.addAttribute(myQName, "My Value");
This works fine as the attribute is properly added.
My problem is when using XMLWriter to serialize the document. I get:
---------------------------
<smil xmlns="http://www.w3.org/2001/SMIL20/Language">
<head xmlns:xm="http://dummyURI.com" xml:lang="My Value">
</head>
</smil>
---------------------------
In fact there are 2 problems:
- The first one seems to be a bug:
it writes "xmlns:xm" instead of "xmlns:xml"
- The second is that I don't want
xmlns:xm="http://dummyURI.com"
to be written out at all, as xml is a default namespace prefix that should
never
be declared in an xml document (a validating parser will generate an error)
Is there any way to prevent dom4j for creating a namespace attribute as soon as
I add an attribute with a namespace that is not already declared in the
document ?
And another very last question:
the xmlns attribute of my <smil> element doesn't appear as an attribute in
the dom4j tree, but as a child (the first one) of the <smil> element, with the
"org.dom4j.Namespace" type.
Is it standard amongst dom-like xml libraries ? (using specific child nodes
instead of "normal" attributes)
Thank you very much for your replies !
Cheers,
Daniel
-------------------------------------------------------
This SF.NET email is sponsored by: A Thawte Code Signing Certificate
is essential in establishing user confidence by providing assurance of
authenticity and code integrity. Download our Free Code Signing guide:
http://ads.sourceforge.net/cgi-bin/redirect.pl?thaw0028en
_______________________________________________
dom4j-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/dom4j-user