You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-dev@xerces.apache.org by Peter Luttrell <pe...@firepod.com> on 2000/09/07 23:09:18 UTC
Help with Defer-Dom-Expansion feature
I have an issue that is happening when I set the
http://apache.org/xml/features/dom/defer-node-expansion feature to false
with the DOMParser.
The problem is that when I call getNodeValue(), I get the value of "2"
returned in consistent situations where the value is a different number.
Here is a little more information:
Here is the key calls in my code:
DOMParser parser = new DOMParser();
parser.setErrorHandler(new ParserErrorHandler());
parser.setFeature("http://xml.org/sax/features/validation", true);
parser.setFeature("http://apache.org/xml/features/validation/dynamic",
true);
parser.setFeature("http://apache.org/xml/features/dom/include-ignorable-wh
itespace", false);
parser.setFeature("http://apache.org/xml/features/dom/defer-node-expansion
", false);
parser.parse( new InputSource( uri to xml doc );
document = parser.getDocument();
Element docElement = document.getDocumentElement();
..then I work through the dom tree to get what I need, most of which are
stored in attributes
I obtain the attribute the following way:
Attr attribute = theparticularsubelement.getAttributeNode(attributeName);
String nodeValue = attribute.getNodeValue();
I am getting nodeValue to be returned as "2" in many situations that can
be consistently reproduced.
This problem does not occur if defer-node-expansion is set to true, the
default. The reason that I have defer-node-expansion set to false is that
I experienced several NullPointerExceptions from within the Xerces classes
when I parsed several large xml docs very rapidly. I'm not sure what the
issue was, however setting defer-node-expansion to false seamed to fix the
problem, with the above side effect.
Background and environment that I am working in:
jdk 1.3
xerces version 1.2
I think that my problem is either there is a bug in xerces or I'm doing
something wrong. I would suspect that it is more likely that I am doing
something wrong. Does anyone know what is going on and more importantly
how to fix it? We are supposed to go live with this code tomorrow, however
this issue will probably prevent us. Any help is much appreciated.
thanks in advance.
RE: Help with Defer-Dom-Expansion feature
Posted by Peter Luttrell <pe...@firepod.com>.
This sounds close to my situation, however I am not using default values,
however something below my call might be.
Here is my method:
public static String getAttributeString(Node node, String
strAttributeName) {
NamedNodeMap nodeMap = node.getAttributes();
Node attributeNode = nodeMap.getNamedItem(strAttributeName);
if (attributeNode == null){return "";}
return attributeNode.getNodeValue();
}
I also have not explicitly set namespaces on or off. It looks like it is
off by default.
thanks.
> I discovered earlier today that there is a bug in the non deferred DOM
> when namespaces are on and there are default attributes. You can end up
> with the same attribute twice (one with namespace the other without). I
> haven't had the time to really look into it in details and fix it but
> does that match your situation? Is the value you're getting back the
> default value?
> --
> Arnaud Le Hors - IBM Cupertino, XML Technology Group
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-j-dev-help@xml.apache.org
>
>
Re: Help with Defer-Dom-Expansion feature
Posted by Arnaud Le Hors <le...@us.ibm.com>.
I discovered earlier today that there is a bug in the non deferred DOM
when namespaces are on and there are default attributes. You can end up
with the same attribute twice (one with namespace the other without). I
haven't had the time to really look into it in details and fix it but
does that match your situation? Is the value you're getting back the
default value?
--
Arnaud Le Hors - IBM Cupertino, XML Technology Group