
org.iso_relax.catalog.RELAXCatalog Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of isorelax Show documentation
Show all versions of isorelax Show documentation
Unknown version of isorelax library used in JAXB project
The newest version!
package org.iso_relax.catalog;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
import org.xml.sax.Attributes;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.DefaultHandler;
/**
* RELAXCatalog
*
* @since Feb. 23, 2001
* @version Feb. 23, 2001
* @author ASAMI, Tomoharu ([email protected])
*/
public class RELAXCatalog {
private Map grammars_ = new HashMap();
public RELAXCatalog()
throws ParserConfigurationException, SAXException, IOException {
this ("http://www.iso-relax.org/catalog");
}
public RELAXCatalog(String rootURI)
throws ParserConfigurationException, SAXException, IOException {
String catalogFile = rootURI + "/catalog.xml";
SAXParserFactory factory = SAXParserFactory.newInstance();
SAXParser saxParser = factory.newSAXParser();
saxParser.parse(catalogFile, new CatalogHandler());
}
public InputSource getGrammar(String uri) {
String location = (String)grammars_.get(uri);
if (location == null) {
return (null);
}
return (new InputSource(location));
}
class CatalogHandler extends DefaultHandler {
public void startElement(
String namespaceURI,
String localName,
String qName,
Attributes atts
) {
String uri = atts.getValue("uri");
String grammar = atts.getValue("grammar");
grammars_.put(uri, grammar);
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy