| 1 |
package com.thaiopensource.relaxng.parse.sax; |
| 2 |
|
| 3 |
import com.thaiopensource.relaxng.parse.Annotations; |
| 4 |
import com.thaiopensource.relaxng.parse.BuildException; |
| 5 |
import com.thaiopensource.relaxng.parse.CommentList; |
| 6 |
import com.thaiopensource.relaxng.parse.SubParseable; |
| 7 |
import com.thaiopensource.relaxng.parse.SubParser; |
| 8 |
import com.thaiopensource.resolver.xml.sax.SAXResolver; |
| 9 |
import com.thaiopensource.xml.util.WellKnownNamespaces; |
| 10 |
import org.xml.sax.ErrorHandler; |
| 11 |
import org.xml.sax.SAXException; |
| 12 |
|
| 13 |
import java.io.IOException; |
| 14 |
|
| 15 |
public class SAXSubParser<P, NC, L, EA, CL extends CommentList<L>, A extends Annotations<L, EA, CL>> implements |
| 16 |
SubParser<P, NC, L, EA, CL, A> { |
| 17 |
final SAXResolver resolver; |
| 18 |
final ErrorHandler eh; |
| 19 |
|
| 20 |
SAXSubParser(SAXResolver resolver, ErrorHandler eh) { |
| 21 |
this.resolver = resolver; |
| 22 |
this.eh = eh; |
| 23 |
} |
| 24 |
|
| 25 |
public SubParseable<P, NC, L, EA, CL, A> createSubParseable(String href, String base) throws BuildException { |
| 26 |
try { |
| 27 |
return new SAXParseable<P, NC, L, EA, CL, A>(resolver.resolve(href, base, WellKnownNamespaces.RELAX_NG), resolver, eh); |
| 28 |
} |
| 29 |
catch (SAXException e) { |
| 30 |
throw BuildException.fromSAXException(e); |
| 31 |
} |
| 32 |
catch (IOException e) { |
| 33 |
throw new BuildException(e); |
| 34 |
} |
| 35 |
} |
| 36 |
} |