*/
private StyleCategory[] readCategories()
throws Exception {
// Get an XML reader
final XMLReader reader = new SAXParser();
// Construct an entity resolver that looks in the JAR that
// contains the same class as this class, and use it to look
// up the XML file
final JarFileEntityResolver resolver = new JarFileEntityResolver(this);
// add the mapping for the style-catorgories.xml file.
resolver.addSystemIdMapping(
STYLE_CATEGORIES_XML_URI,
STYLE_CATEGORIES_XML_LOCATION);
// add the mapping for the style-catorgories.xsd file.
resolver.addSystemIdMapping(
STYLE_CATEGORIES_SCHEMA_URI,
STYLE_CATEGORIES_SCHEMA_LOCATION);
final InputSource xmlInputSource =
resolver.resolveEntity(null, STYLE_CATEGORIES_XML_URI);
// Create a content handler and attach it to the reader
final StyleCategoryContentHandler handler =
new StyleCategoryContentHandler();
reader.setContentHandler(handler);
reader.setErrorHandler(handler);
reader.setEntityResolver(resolver);
// Turn on schema validation
reader.setFeature(
"http://apache.org/xml/features/validation/schema", true);
// Parse the XML file
reader.parse(xmlInputSource);
// Get the categories from the content handler
final List catsList = handler.getStyleCategories();
StyleCategory[] catsArray = new StyleCategory[catsList.size()];
return (StyleCategory[])