-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix #266 by getting the right resolver into Saxon's config
- Loading branch information
Showing
3 changed files
with
68 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package com.xmlcalabash.util; | ||
|
||
import net.sf.saxon.Configuration; | ||
import net.sf.saxon.lib.ModuleURIResolver; | ||
import net.sf.saxon.lib.UnparsedTextURIResolver; | ||
import net.sf.saxon.trans.XPathException; | ||
import org.xml.sax.EntityResolver; | ||
import org.xml.sax.InputSource; | ||
import org.xml.sax.SAXException; | ||
|
||
import javax.xml.transform.Source; | ||
import javax.xml.transform.TransformerException; | ||
import javax.xml.transform.URIResolver; | ||
import javax.xml.transform.stream.StreamSource; | ||
import java.io.IOException; | ||
import java.io.Reader; | ||
import java.net.URI; | ||
|
||
public class XProcURIResolverX implements URIResolver, EntityResolver, ModuleURIResolver, UnparsedTextURIResolver { | ||
private static XProcURIResolver realResolver = null; | ||
|
||
public XProcURIResolverX() { | ||
// no one can do this | ||
} | ||
|
||
public void setRealResolver(XProcURIResolver resolver) { | ||
realResolver = resolver; | ||
} | ||
|
||
public Source resolve(String href, String base) throws TransformerException { | ||
return realResolver.resolve(href, base); | ||
} | ||
|
||
public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException { | ||
return realResolver.resolveEntity(publicId, systemId); | ||
} | ||
|
||
@Override | ||
public StreamSource[] resolve(String moduleURI, String baseURI, String[] locations) | ||
throws XPathException { | ||
return realResolver.resolve(moduleURI, baseURI, locations); | ||
} | ||
|
||
@Override | ||
public Reader resolve(URI uri, String encoding, Configuration configuration) throws XPathException { | ||
return realResolver.resolve(uri, encoding, configuration); | ||
} | ||
} |