Hi,
I was able to map the xhtml namespace, and it works alright; however,
I've run into an issue. When I do DocumentHelper.createElement it gives
the element an empty namespace. I'd like for all my elements to be of
the same namespace, but I just can't figure out how. Is there ANY way
to remove the xhtml namespace altogether? Maybe I could load the doc
with a slightly modified doctype, then before I print change it to a
standard xhtml one? If it's possible, I suppose I'd be okay with making
my own createElement function and setting the new element's namespace to
the xhtml namespace. I've tried this, but can't get it to work.
Thanks much,
--Evan
Edwin Dankert wrote:
Why it fails is because of the following lines in the XHTML DTD:
<!ELEMENT html (head, body)>
<!ATTLIST html
%i18n;
id ID #IMPLIED
xmlns %URI; #FIXED 'http://www.w3.org/1999/xhtml'
>
This will add a default namespace to your XML, so your XML in reality
looks like:
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Title</title>
<style>
body{
background: blue;
}
</style>
</head>
<body>
<div id="main">
HI!
</div>
</body>
</html>
Note to XML designers, please avoid using fixed 'xmlns' attributes in your
DTDs.
To fix this, you will have to map your namespace-URI to a prefix and then
use this prefix in your XPath searches.
Please have a look at previous mails to this list to find out how to do this.
For some more background information:
http://www.edankert.com/defaultnamespaces.html
Regards,
Edwin
--
http://www.edankert.com/
N�HY隊X���'���u���[�������
ަ�k��!���W�~�鮆�zk��C� [EMAIL PROTECTED],���a{�
�,�H��4�m���i�(��ܢo�v'��jYhr'ׯ:�rX���&�;�z���X��X���&�;�z�b��,���y�+��m����+-��.�ǟ�����+-��b�ا~�ݢn#�ǫ
-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems? Stop! Download the new AJAX search engine that makes
searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid3432&bid#0486&dat1642
_______________________________________________
dom4j-user mailing list
dom4j-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/dom4j-user