Permalink
Browse files

Fix issue #137; make base URI and static base URI configurable for be…

…tter integration into eXist
  • Loading branch information...
ndw committed Feb 9, 2014
1 parent 88f7dd1 commit 86b7e863b02b2acefcbba63244aba5e499202483
@@ -71,30 +71,6 @@
import org.xml.sax.EntityResolver;
import org.xml.sax.InputSource;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.lang.reflect.Constructor;
import java.net.URI;
import java.net.URISyntaxException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.Hashtable;
import java.util.Locale;
import java.util.Vector;
import java.util.logging.Logger;
import javax.xml.transform.URIResolver;
import javax.xml.transform.sax.SAXSource;
import com.xmlcalabash.config.XProcConfigurer;
import com.xmlcalabash.functions.BaseURI;
import com.xmlcalabash.functions.Cwd;
@@ -146,6 +122,7 @@
private static String episode = null;
private Hashtable<String,Vector<XdmNode>> collections = null;
private URI staticBaseURI = null;
private URI baseURI = null;
private boolean allowGeneralExpressions = true;
private boolean allowXPointerOnText = true;
private boolean transparentJSON = false;
@@ -346,6 +323,18 @@ public URI getStaticBaseURI() {
return staticBaseURI;
}
public void setStaticBaseURI(URI staticBaseURI) {
this.staticBaseURI = staticBaseURI;
}
public URI getBaseURI() {
return baseURI;
}
public void setBaseURI(URI baseURI) {
this.baseURI = baseURI;
}
public String getSendmailHost() {
return config.mailHost;
}
@@ -589,7 +578,11 @@ private XPipeline _load(Input pipelineInput) throws SaxonApiException, IOExcepti
configurer.getXMLCalabashConfigurer().configRuntime(this);
switch (pipelineInput.getKind()) {
case URI:
pipeline = parser.loadPipeline(pipelineInput.getUri());
if (baseURI == null) {
pipeline = parser.loadPipeline(pipelineInput.getUri());
} else {
pipeline = parser.loadPipeline(pipelineInput.getUri(), baseURI.toASCIIString());
}
break;
case INPUT_STREAM:
@@ -86,7 +86,11 @@ public DeclareStep loadPipeline(InputStream inputStream) throws SaxonApiExceptio
}
public DeclareStep loadPipeline(String uri) throws SaxonApiException {
XdmNode doc = runtime.parse(uri, URIUtils.cwdAsURI().toASCIIString());
return loadPipeline(uri, URIUtils.cwdAsURI().toASCIIString());
}
public DeclareStep loadPipeline(String uri, String base) throws SaxonApiException {
XdmNode doc = runtime.parse(uri, base);
return loadPipeline(doc);
}
@@ -786,7 +786,11 @@ protected RuntimeValue computeValue(ComputableValue var) {
try {
XPathCompiler xcomp = runtime.getProcessor().newXPathCompiler();
URI baseURI = step.getNode().getBaseURI();
if (!"".equals(baseURI.toASCIIString())) {
if (baseURI == null || !baseURI.isAbsolute()) {
if (runtime.getBaseURI() != null) {
xcomp.setBaseURI(runtime.getBaseURI().resolve(baseURI));
}
} else {
xcomp.setBaseURI(baseURI);
}
@@ -64,38 +64,38 @@
import static net.sf.saxon.s9api.QName.fromClarkName;
public class UserArgs {
private boolean needsCheck = false;
private Boolean debug = null;
private Output profile = null;
private boolean showVersion = false;
private String saxonProcessor = null;
private Input saxonConfig = null;
private boolean schemaAware = false;
private Boolean safeMode = null;
private Input config = null;
private String logStyle = null;
private String entityResolverClass = null;
private String uriResolverClass = null;
private Input pipeline = null;
private List<Input> libraries = new ArrayList<Input>();
private Map<String, Output> outputs = new HashMap<String, Output>();
private Map<String, String> bindings = new HashMap<String, String>();
private List<StepArgs> steps = new ArrayList<StepArgs>();
private StepArgs curStep = new StepArgs();
private StepArgs lastStep = null;
private boolean extensionValues = false;
private boolean allowXPointerOnText = false;
private boolean useXslt10 = false;
private boolean transparentJSON = false;
private String jsonFlavor = null;
private Integer piperackPort = null;
private Integer piperackExpires = null;
protected boolean needsCheck = false;
protected Boolean debug = null;
protected Output profile = null;
protected boolean showVersion = false;
protected String saxonProcessor = null;
protected Input saxonConfig = null;
protected boolean schemaAware = false;
protected Boolean safeMode = null;
protected Input config = null;
protected String logStyle = null;
protected String entityResolverClass = null;
protected String uriResolverClass = null;
protected Input pipeline = null;
protected List<Input> libraries = new ArrayList<Input>();
protected Map<String, Output> outputs = new HashMap<String, Output>();
protected Map<String, String> bindings = new HashMap<String, String>();
protected List<StepArgs> steps = new ArrayList<StepArgs>();
protected StepArgs curStep = new StepArgs();
protected StepArgs lastStep = null;
protected boolean extensionValues = false;
protected boolean allowXPointerOnText = false;
protected boolean useXslt10 = false;
protected boolean transparentJSON = false;
protected String jsonFlavor = null;
protected Integer piperackPort = null;
protected Integer piperackExpires = null;
public void setDebug(boolean debug) {
this.debug = debug;
}
private void setProfile(Output profile) {
protected void setProfile(Output profile) {
needsCheck = true;
if ((this.profile != null) && (profile != null)) {
throw new XProcException("Multiple profile are not supported.");
@@ -139,7 +139,7 @@ public void setSaxonProcessor(String saxonProcessor) {
}
}
private void setSaxonConfig(Input saxonConfig) {
protected void setSaxonConfig(Input saxonConfig) {
needsCheck = true;
if ((this.saxonConfig != null) && (saxonConfig != null)) {
throw new XProcException("Multiple saxonConfig are not supported.");
@@ -168,7 +168,7 @@ public void setSafeMode(boolean safeMode) {
this.safeMode = safeMode;
}
private void setConfig(Input config) {
protected void setConfig(Input config) {
if ((this.config != null) && (config != null)) {
throw new XProcException("Multiple config are not supported.");
}
@@ -208,7 +208,7 @@ public Input getPipeline() {
return pipeline;
}
private void setPipeline(Input pipeline) {
protected void setPipeline(Input pipeline) {
needsCheck = true;
if ((this.pipeline != null) && (pipeline != null)) {
throw new XProcException("Multiple pipelines are not supported.");

0 comments on commit 86b7e86

Please sign in to comment.