Methods Summary |
---|
public void | characters(char[] ch, int start, int length)
if (null != sb) {
sb.append(ch, start, length);
}
|
public void | endElement(java.lang.String uri, java.lang.String localName, java.lang.String qName)
if (localName.equals("messages")){ // do nothing
} else if (localName.equals("message")) {
endMessage();
} else {
throw new SAXException("Unknown element: "+uri+":"+localName);
}
|
private void | endMessage()
if (null != sb){
properties.setProperty(key, sb.toString().trim());
}
sb = null;
|
java.util.Properties | getProperties()
return properties;
|
public static void | main(java.lang.String[] args)
if (args.length < 2 || 3 < args.length ){
useage();
System.exit(1);
}
final String prefix = (args.length == 2 ? null : args[0]);
final String in = (args.length == 2 ? args[0] : args[1]);
final String out = (args.length == 2 ? args[1] : args[2]);
final MakeCatalog mc = new MakeCatalog(prefix);
final InputSource is = new InputSource(new FileReader(new File(in)));
is.setSystemId(in);
mc.makeCatalog(is);
mc.getProperties().save(new FileOutputStream(new File(out)), null);
System.exit(0);
|
void | makeCatalog(org.xml.sax.InputSource is)
// final SAXParserFactory spf = SAXParserFactory.newInstance();
final SAXParserFactory spf = new com.sun.msv.verifier.jaxp.SAXParserFactoryImpl();
spf.setNamespaceAware(true);
spf.setValidating(false);
spf.setFeature(NAMESPACES, true);
spf.setFeature(PREFIXES, false);
final SAXParser p = spf.newSAXParser();
p.setProperty("http://www.sun.com/xml/msv/schema", SCHEMA);
// spf.newSAXParser().parse(is, this);
p.parse(is, this);
|
public void | startDocument()
properties = new Properties();
|
public void | startElement(java.lang.String uri, java.lang.String localName, java.lang.String qName, org.xml.sax.Attributes attributes)
if (null == localName){
throw new SAXException("localName is null");
}
if (localName.equals("messages")){ // do nothing
} else if (localName.equals("message")) {
startMessage(attributes);
} else {
throw new SAXException("Unknown element: "+uri+":"+localName);
}
|
private void | startMessage(org.xml.sax.Attributes attributes)
key = (prefix != null ? prefix : "") + attributes.getValue("", "id");
if (null == key){
throw new SAXException("message element had no id attribute");
}
sb = new StringBuffer();
|
private static void | useage()
System.err.println("Useage: MakeCatalog [prefix] in out");
|