Below is a sample that I believe could help to do what you want.
Up vote 2 down vote favorite share g+ share fb share tw.
I need to parse a bunch of incoming XML documents but it does not contain DTD declaration. Currently I am parsing xml documents using SAX Parser but without DTD validation. Now I want to apply DTD validation.
DTD is created by myself. How can I validate an XML file using DTD created by myself (SAX parser)? I found some tutorials using Transformer but all for DOM Parser.
How to parse XML file using SAX Parser and also applying DTD validation. Any help.... java android xml dtd saxparser link|improve this question asked Nov 11 '11 at 8:44Khushbu2519 62% accept rate.
Below is a sample that I believe could help to do what you want: private void loadXML(Reader reader) throws ParserConfigurationException, SAXException { SAXParserFactory parserFactory = SAXParserFactory.newInstance(); parserFactory. SetValidating(true); SAXParser parser = parserFactory.newSAXParser(); parser. Parse(new InputSource(reader), new MyHandler()); } private static class MyHandler extends DefaultHandler { private static final String PREFS_DTD_URI = "http://www.example.com/dtd/document.dtd"; public InputSource resolveEntity(String publicId, String systemId) throws SAXException { if (systemId.
Equals(PREFS_DTD_URI)) { InputSource is = new InputSource(new StringReader(PREFS_DTD)); // PREFS_DTD is a string containing actual DTD, any other Reader could be here is. SetSystemId(PREFS_DTD_URI); return is; } // else use the default behaviour return null; } }.
ParserFactory. SetValidating(true); line gives Parserconfigurationexception in android and give warning that no implementation of validation is supported. It works in java but not in android.
Is there any other method to give dtd validation in android? – Khushbu Nov 26 '11 at 5:21.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.