Hi,
If this is a FAQ, please excuse and point me to the right location. I did my
homework, but did not find any suitable information.
I have the following problem: I would like to parse and validate an XML document
and access this XML document via DOM afterwards. As the related schema makes
extensive use of the "normalizedString" and "token" datatypes (i.e. those with
the whiteSpace facet with "replace" and "collapse" values), I would like to
access the whitespace normalized values rather than the actual values contained
in the original XML document to avoid a manual normalization at every location
in my code.
I saw that Xerces (I tried the latest version 2.7.0) supports a feature called
"http://.../normalized-value". However, I see no difference when I set this to
"true". The DOM nodes still contain the unnormalized values. I also set the
other required features as documented. I verified that validation is actually
performed, i.e. parsing an invalid document does result in an exception.
I use the following way to create the parser (javax.xml.* classes under JDK
1.5):
- - - 8< - - -
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance ();
dbf.setNamespaceAware (true);
dbf.setSchema (profile.getSchema ());
dbf.setValidating (true);
dbf.setFeature ("http://apache.org/xml/features/validation/dynamic", true);
dbf.setFeature ("http://xml.org/sax/features/validation", true);
dbf.setFeature ("http://apache.org/xml/features/validation/schema", true);
dbf.setFeature
("http://apache.org/xml/features/validation/schema-full-checking", true);
dbf.setFeature
("http://apache.org/xml/features/validation/schema/normalized-value", true);
dbf.setFeature
("http://apache.org/xml/features/validation/schema/element-default", true);
DocumentBuilder db = dbf.newDocumentBuilder ();
SaxErrorHandler eh = new SaxErrorHandler (ctx);
db.setErrorHandler (eh);
ByteArrayInputStream bis = new ByteArrayInputStream (data);
return db.parse (bis);
- - - 8< - - -
Any ideas, comments on what I am doing wrong? Or do I misunderstand this
feature?
Thanks in advance for any feedback.
regards,
Klaus
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]