xerces-j-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Klaus Malorny <Klaus.Malo...@knipp.de>
Subject "normalized-value" feature of Xerces
Date Tue, 12 Jul 2005 08:54:58 GMT


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);
   ("http://apache.org/xml/features/validation/schema-full-checking", true);
   ("http://apache.org/xml/features/validation/schema/normalized-value", true);
   ("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.



To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-users-help@xerces.apache.org

View raw message