lexer.setContentHandler(parser);
parser.setContentHandler(serializer);
// Push text into this pipeline
// Create locator, which help to find possible syntax errors
LocatorImpl locator = new LocatorImpl();
locator.setSystemId(inFile.toURL().toString());
locator.setLineNumber(1);
locator.setColumnNumber(1);
lexer.setDocumentLocator(locator);
// Start document
lexer.startDocument();
// Start 'text' element, which the parser dispatch
lexer.startElement("http://chaperon.sourceforge.net/schema/text/1.0", "text", "text",
new AttributesImpl());
LineNumberReader reader =
new LineNumberReader(new InputStreamReader(new FileInputStream(inFile)));
String line;
String newline = null;
String separator = System.getProperty("line.separator");
// Push text
while (true)
{
if (newline==null)
line = reader.readLine();
else
line = newline;
if (line==null)
break;
newline = reader.readLine();
line = (newline!=null) ? (line+separator) : line;
locator.setLineNumber(reader.getLineNumber());
locator.setColumnNumber(1);
lexer.characters(line.toCharArray(), 0, line.length());
if (newline==null)
break;
}