You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xerces.apache.org by "Decoker, Lydie (Lydie)" <de...@lucent.com> on 2006/09/19 11:55:42 UTC
Default attributes and elements
How to add in the DOM tree the default attributes and elements?
What I did is the following:
// Set the DocumentBuilderFactory system property
System.setProperty("javax.xml.parsers.DocumentBuilderFactory","org.apach
e.xerces.jaxp.DocumentBuilderFactoryImpl");
System.setProperty("javax.xml.validation.SchemaFactory:http://www.w3.org
/2001/XMLSchema", "org.apache.xerces.jaxp.validation.XMLSchemaFactory");
// Create the dom factory
DocumentBuilderFactory domFactory=DocumentBuilderFactory.newInstance();
System.out.println("Document builder factory class: " +
domFactory.getClass().getName());
// Set the namespace property
domFactory.setNamespaceAware(true);
// Set the validation property
domFactory.setValidating(true);
// Set the schema language property to be used for validation
domFactory.setAttribute("http://java.sun.com/xml/jaxp/properties/schemaL
anguage", XMLConstants.W3C_XML_SCHEMA_NS_URI);=09
// Specify the XML schema document to be used for validation
domFactory.setAttribute(JMSValidator.JAXP_SCHEMA_SOURCE, new
File(schemaLocation));
domFactory.setAttribute("http://xml.org/sax/features/validation", true);
domFactory.setAttribute("http://apache.org/xml/features/validation/schem
a", true);
domFactory.setAttribute("http://apache.org/xml/features/validation/schem
a/element-default",true);
But when printing out the "augmented" document, the default values were
not added.
Any help would be appreciated.
---------------------------------------------------------------------
To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-users-help@xerces.apache.org