Hi Kristian,
On Mon, 2005-02-28 at 17:43 +0100, Kristian Mandrup wrote:
> Added PREFIX namespace support for NodeCreateRule: Can now parse a XML Schema
> correctly â
> Tested (see Junit TestCase below). Works fine!
[snip]
> if ((localName == null) || (localName.length() == 0)) {
> top = doc.createElement(qName);
> } else {
> top = doc.createElementNS(namespaceURI, localName);
> }
> String prefix = qName.split(":")[0];
> if (prefix != null) {
> top.setPrefix(prefix);
> }
This seems to ensure that if an xml document containing namespaces is parsed
with
a non-namespace-aware xml parser (ie localName is not defined), then a DOM-1
(ie non-namespace-aware) element node is created ("createElement"), but then
the namespace-aware "setPrefix" method is called on it.
It seems to me that if the createElement (ie non-namespace-aware) method
is called to create the attribute, then calling setPrefix (ie a
namespace-aware method) is a bad idea. A prefix is being set, but there
is no namespace URI associated with the node...
> for (int i = 0; i < atts.getLength(); i++) {
> Attr attr = null;
> String attQname = atts.getQName(i);
> prefix = null;
> if (attQname.contains(":"))
> prefix = attQname.split(":")[0];
> if ((atts.getLocalName(i) == null) ||
> (atts.getLocalName(i).length() == 0)) {
> attr = doc.createAttribute(attQname);
> attr.setNodeValue(atts.getValue(i));
> if (prefix != null) {
> attr.setPrefix(prefix);
> }
This seems to have the same issue as described above; it seems to me
that if the createAttribute (ie non-namespace-aware) method is called to
create the attribute, then calling setPrefix (ie a namespace-aware
method) is a bad idea. A prefix is being set, but there is no namespace
URI associated with the node...
If I have misunderstood your patch, please let me know.
What is the problem that you are encountering with the current code that
this patch is intended to remedy?
Regards,
Simon
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]