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 buzzonus <bu...@yahoo.com> on 2001/05/02 18:30:55 UTC
enabling validation results in a problem
Hi,
I am using xerces 1.3.0 and am running into a problem where the XPathAPI.selectNodeList does
not return the expected nodes when I parse an xml file with ""http://xml.org/sax/features/validation" feature turned on. It works fine when this feature is disabled, i.e. set to false.Is this a know bug or I a missing something ?
Because if this problem, I now have to parse the file twice to get it into a dom..first with validation turned on and then with validation turned off (in the case when validation is a success)..this impact the the overall response time in my application.
here is what my test code look like :
....
DOMParser parser = new DOMParser();
parser.setFeature( "http://xml.org/sax/features/namespaces",
true);
parser.setFeature( "http://xml.org/sax/features/validation",
validation);
parser.setFeature( "http://apache.org/xml/features/validation/schema",
true );
parser.parse(pData2);
doc = parser.getDocument();
if (doc != null)
{
Element elm = doc.getDocumentElement();
if (el != null)
{
System.out.println("docs root element tag name ="+elm.getTagName());
try
{
NodeList nodes = XPathAPI.selectNodeList(doc,
new String("descendant::tiger"));
if (nodes == null)
{
System.out.println("did not find our tiger element");
}
else
System.out.println("found "+nodes.getLength()+" tiger elements");
}
.....
Here is the output for my sample xml:
1)with validation set to true:
docs root element tag name =abc
found 2 tiger elements
2)with validation set to false:
docs root element tag name =abc
found 0 tiger elements
any feedback would be appreciated.
thanks.
Sing