KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > thaiopensource > relaxng > parse > sax > SAXParseable


1 package com.thaiopensource.relaxng.parse.sax;
2
3 import com.thaiopensource.xml.sax.XMLReaderCreator;
4 import com.thaiopensource.relaxng.parse.BuildException;
5 import com.thaiopensource.relaxng.parse.IllegalSchemaException;
6 import com.thaiopensource.relaxng.parse.Parseable;
7 import com.thaiopensource.relaxng.parse.ParsedPattern;
8 import com.thaiopensource.relaxng.parse.SchemaBuilder;
9 import com.thaiopensource.relaxng.parse.Scope;
10 import org.xml.sax.ErrorHandler JavaDoc;
11 import org.xml.sax.InputSource JavaDoc;
12 import org.xml.sax.SAXException JavaDoc;
13 import org.xml.sax.XMLReader JavaDoc;
14
15 import java.io.IOException JavaDoc;
16
17 public class SAXParseable extends SAXSubParser implements Parseable {
18   private final InputSource JavaDoc in;
19
20   public SAXParseable(XMLReaderCreator xrc, InputSource JavaDoc in, ErrorHandler JavaDoc eh) {
21     super(xrc, eh);
22     this.in = in;
23   }
24
25   public ParsedPattern parse(SchemaBuilder schemaBuilder, Scope scope) throws BuildException, IllegalSchemaException {
26     try {
27       XMLReader JavaDoc xr = xrc.createXMLReader();
28       SchemaParser sp = new SchemaParser(xr, eh, schemaBuilder, null, scope);
29       xr.parse(in);
30       return sp.getParsedPattern();
31     }
32     catch (SAXException JavaDoc e) {
33       throw toBuildException(e);
34     }
35     catch (IOException JavaDoc e) {
36       throw new BuildException(e);
37     }
38   }
39
40 }
41
Popular Tags