Java/XML/XMLResolver
Версия от 18:01, 31 мая 2010; (обсуждение)
Input Object Properties
import java.io.FileInputStream;
import javax.xml.stream.XMLEventReader;
import javax.xml.stream.XMLEventWriter;
import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLOutputFactory;
import javax.xml.stream.XMLResolver;
import javax.xml.stream.XMLStreamException;
public class MainClass {
public static void main(String[] args) throws Exception {
XMLInputFactory inputFactory = XMLInputFactory.newInstance();
inputFactory.setXMLResolver(new XMLResolver() {
public Object resolveEntity(String publicID, String systemID, String baseURI, String namespace)
throws XMLStreamException {
System.out.println(systemID);
return null;
}
});
XMLEventReader reader = inputFactory.createXMLEventReader(new FileInputStream(
"dtd.xml"));
XMLEventWriter writer = XMLOutputFactory.newInstance().createXMLEventWriter(System.out);
writer.add(reader);
writer.flush();
}
}