142
Designing XML Based Applications
return false;
}
Code Example 4.6
Ensuring the Expected Type of a DTD Conforming Document
public static final String W3C_XML_SCHEMA
= "http://www.w3.org/2001/XMLSchema";
public static final String JAXP_SCHEMA_LANGUAGE
= "http://java.sun.com/xml/jaxp/properties/schemaLanguage";
public static final String JAXP_SCHEMA_SOURCE
= "http://java.sun.com/xml/jaxp/properties/schemaSource";
public static SAXParser createParser(boolean validating,
boolean xsdSupport, CustomEntityResolver entityResolver,
String schemaURI) throws ... {
// Obtain a SAX parser from a SAX parser factory
SAXParserFactory parserFactory
= SAXParserFactory.newInstance();
// Enable validation
parserFactory.setValidating(validating);
parserFactory.setNamespaceAware(true);
SAXParser parser = parserFactory.newSAXParser();
if (xsdSupport) { // XML Schema Support
try {
// Enable XML Schema validation 
parser.setProperty(JAXP_SCHEMA_LANGUAGE,
W3C_XML_SCHEMA);
// Set the validating schema to the resolved schema URI
parser.setProperty(JAXP_SCHEMA_SOURCE,
entityResolver.mapEntityURI(schemaURI));
} catch(SAXNotRecognizedException exception) { ... }
}
return parser;
}
Code Example 4.7
Setting the Parser for Validation in JAXP 1.2 






New Page 1








Home : About Us : Network : Services : Support : FAQ : Control Panel : Order Online : Sitemap : Contact : Terms Of Service

java web hosting

 

 

 Our partners: | PHP: Hypertext Preprocessor | Best Web Hosting | Java Web Hosting | Inexpensive Web Hosting |

Jsp Web Hosting | Cheapest Web Hosting | Jsp Hosting | Cheap Hosting

 

Virtualwebstudio. Business web hosting division of Web Design Plus. All rights reserved