Permalink
Browse files

Apply patch for issue #124 to the saxon95 branch

  • Loading branch information...
ndw committed Oct 23, 2013
2 parents 2df89cc + 9976a12 commit 00b04cda37ad9ca232aad07925d5f5cf37a67e4a
View
48 pom.xml
@@ -209,17 +209,23 @@
<execution>
<id>default-compile</id>
<configuration>
<compilerArguments>
<bootclasspath>${bootclasspath.compile}</bootclasspath>
</compilerArguments>
<compilerArgs>
<arg>-Xlint</arg>
<arg>-Xlint:-serial</arg>
<arg>-bootclasspath</arg>
<arg>${bootclasspath.compile}</arg>
</compilerArgs>
</configuration>
</execution>
<execution>
<id>default-testCompile</id>
<configuration>
<compilerArguments>
<bootclasspath>${bootclasspath.testCompile}</bootclasspath>
</compilerArguments>
<compilerArgs>
<arg>-Xlint</arg>
<arg>-Xlint:-serial</arg>
<arg>-bootclasspath</arg>
<arg>${bootclasspath.testCompile}</arg>
</compilerArgs>
</configuration>
</execution>
</executions>
@@ -265,19 +271,21 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<showWarnings>true</showWarnings>
<showDeprecation>true</showDeprecation>
<source>1.6</source>
<target>1.6</target>
<compilerArgs>
<arg>-Xlint</arg>
<arg>-Xlint:-serial</arg>
</compilerArgs>
</configuration>
<executions>
<execution>
<id>default-compile</id>
<configuration>
<showWarnings>true</showWarnings>
<showDeprecation>true</showDeprecation>
<compilerArgument>-Xlint:-serial</compilerArgument>
<compilerArguments>
<Xlint/>
</compilerArguments>
<source>1.6</source>
<target>1.6</target>
<excludes>
<!-- Requires Delta XML Core (not available through Maven) -->
<exclude>com/xmlcalabash/extensions/DeltaXML.java</exclude>
@@ -302,16 +310,6 @@
<execution>
<id>default-testCompile</id>
<configuration>
<showWarnings>true</showWarnings>
<showDeprecation>true</showDeprecation>
<compilerArgument>-Xlint:-serial</compilerArgument>
<compilerArguments>
<Xlint/>
</compilerArguments>
<source>1.6</source>
<target>1.6</target>
</configuration>
</execution>
</executions>
</plugin>
@@ -444,7 +444,7 @@ public void parse(XdmNode doc) {
public boolean isStepAvailable(QName type) {
if (implementations.containsKey(type)) {
Class klass = implementations.get(type);
Class<?> klass = implementations.get(type);
try {
Method method = klass.getMethod("isAvailable");
Boolean available = (Boolean) method.invoke(null);
@@ -462,7 +462,7 @@ public boolean isStepAvailable(QName type) {
}
public XProcStep newStep(XProcRuntime runtime,XAtomicStep step){
Class klass = implementations.get(step.getType());
Class<?> klass = implementations.get(step.getType());
if (klass == null) {
throw new XProcException("Misconfigured. No 'class' in configuration for " + step.getType());
}
@@ -474,8 +474,8 @@ public XProcStep newStep(XProcRuntime runtime,XAtomicStep step){
}
try {
Constructor constructor = Class.forName(className).getConstructor(XProcRuntime.class, XAtomicStep.class);
return (XProcStep) constructor.newInstance(runtime,step);
Constructor<? extends XProcStep> constructor = Class.forName(className).asSubclass(XProcStep.class).getConstructor(XProcRuntime.class, XAtomicStep.class);
return constructor.newInstance(runtime,step);
} catch (NoSuchMethodException nsme) {
throw new UnsupportedOperationException("No such method: " + className, nsme);
} catch (ClassNotFoundException cfne) {
@@ -828,7 +828,7 @@ private void parseImplementation(XdmNode node) {
for (String tname : nameStr.split("\\s+")) {
QName name = new QName(tname,node);
try {
Class klass = Class.forName(value);
Class<?> klass = Class.forName(value);
implementations.put(name, klass);
} catch (ClassNotFoundException e) {
// nop
@@ -177,8 +177,8 @@ public XProcRuntime(XProcConfiguration config) {
if (config.xprocConfigurer != null) {
try {
String className = config.xprocConfigurer;
Constructor constructor = Class.forName(className).getConstructor(XProcRuntime.class);
configurer = (XProcConfigurer) constructor.newInstance(this);
Constructor<? extends XProcConfigurer> constructor = Class.forName(className).asSubclass(XProcConfigurer.class).getConstructor(XProcRuntime.class);
configurer = constructor.newInstance(this);
} catch (Exception e) {
throw new XProcException(e);
}
@@ -212,14 +212,14 @@ public XProcRuntime(XProcConfiguration config) {
try {
if (config.uriResolver != null) {
uriResolver.setUnderlyingURIResolver((URIResolver) Class.forName(config.uriResolver).newInstance());
uriResolver.setUnderlyingURIResolver(Class.forName(config.uriResolver).asSubclass(URIResolver.class).newInstance());
}
if (config.entityResolver != null) {
uriResolver.setUnderlyingEntityResolver((EntityResolver) Class.forName(config.entityResolver).newInstance());
uriResolver.setUnderlyingEntityResolver(Class.forName(config.entityResolver).asSubclass(EntityResolver.class).newInstance());
}
if (config.errorListener != null) {
msgListener = (XProcMessageListener) Class.forName(config.errorListener).newInstance();
msgListener = Class.forName(config.errorListener).asSubclass(XProcMessageListener.class).newInstance();
} else {
msgListener = new DefaultXProcMessageListener();
}
@@ -28,6 +28,7 @@
import java.util.List;
import java.util.Map;
import java.util.Vector;
import javax.xml.transform.URIResolver;
import com.xmlcalabash.util.Input.Type;
import com.xmlcalabash.util.UserArgs;
@@ -47,6 +48,7 @@
import org.apache.tools.ant.types.resources.Resources;
import org.apache.tools.ant.types.resources.Union;
import org.apache.tools.ant.util.FileNameMapper;
import org.xml.sax.EntityResolver;
import static com.xmlcalabash.util.Input.Type.DATA;
import static com.xmlcalabash.util.Input.Type.XML;
@@ -862,7 +864,7 @@ public void setLogStyle(String logStyle) {
*
* @param entityResolver the resolver class for entity resolution
*/
public void setEntityResolver(Class entityResolver) {
public void setEntityResolver(Class<? extends EntityResolver> entityResolver) {
try {
userArgs.setEntityResolverClass(entityResolver.getName());
} catch (Exception e) {
@@ -875,7 +877,7 @@ public void setEntityResolver(Class entityResolver) {
*
* @param uriResolver the resolver class for URI resolution
*/
public void setURIResolver(Class uriResolver) {
public void setURIResolver(Class<? extends URIResolver> uriResolver) {
try {
userArgs.setUriResolverClass(uriResolver.getName());
} catch (Exception e) {
@@ -895,8 +897,8 @@ public void addConfiguredLibrary(UseableResources libraries) {
}
try {
for (Iterator iterator = libraries.iterator(); iterator.hasNext(); ) {
Resource library = (Resource) iterator.next();
for (Iterator<Resource> iterator = libraries.iterator(); iterator.hasNext(); ) {
Resource library = iterator.next();
userArgs.addLibrary(library.getInputStream(), library.toString());
}
} catch (Exception e) {
@@ -1262,8 +1264,8 @@ private void process(Map<String, List<TypedResource>> inputResources, Map<String
try {
for (String port : outputResources.keySet()) {
Union resources = outputResources.get(port);
for (Iterator iterator = resources.iterator(); iterator.hasNext(); ) {
Resource resource = (Resource) iterator.next();
for (Iterator<Resource> iterator = resources.iterator(); iterator.hasNext(); ) {
Resource resource = iterator.next();
userArgs.addOutput(port, resource.getOutputStream());
}
}
@@ -89,13 +89,13 @@ public void run() throws SaxonApiException {
tree.startContent();
// iterate through metadata directories
Iterator directories = metadata.getDirectories().iterator();
Iterator<Directory> directories = metadata.getDirectories().iterator();
while (directories.hasNext()) {
Directory directory = (Directory) directories.next();
Directory directory = directories.next();
String dir = directory.getName();
Iterator tags = directory.getTags().iterator();
Iterator<Tag> tags = directory.getTags().iterator();
while (tags.hasNext()) {
Tag tag = (Tag) tags.next();
Tag tag = tags.next();
tree.addStartElement(c_tag);
tree.addAttribute(_dir, dir);
@@ -174,7 +174,7 @@ public void run(String imageFn) {
while (!imageFailed && (width == -1 || depth == -1)) {
try {
java.lang.Thread.currentThread().sleep(50);
Thread.sleep(50);
} catch (Exception e) {
// nop;
}
@@ -297,9 +297,9 @@ public void update(ZipFile inZip, ZipOutputStream outZip, boolean freshen) {
try {
if (inZip != null) {
Enumeration zenum = inZip.entries();
Enumeration<? extends ZipEntry> zenum = inZip.entries();
while (zenum.hasMoreElements()) {
ZipEntry entry = (ZipEntry) zenum.nextElement();
ZipEntry entry = zenum.nextElement();
String name = entry.getName();
boolean skip = srcManifest.containsKey(name);
@@ -405,9 +405,9 @@ public void update(ZipFile inZip, ZipOutputStream outZip, boolean freshen) {
public void delete(ZipFile inZip, ZipOutputStream outZip) {
try {
if (inZip != null) {
Enumeration zenum = inZip.entries();
Enumeration<? extends ZipEntry> zenum = inZip.entries();
while (zenum.hasMoreElements()) {
ZipEntry entry = (ZipEntry) zenum.nextElement();
ZipEntry entry = zenum.nextElement();
String name = entry.getName();
boolean delete = false;
@@ -76,7 +76,6 @@ public ExtensionFunctionCall makeCallExpression() {
private class CwdCall extends ExtensionFunctionCall {
public Sequence call(XPathContext xPathContext, Sequence[] sequences) throws XPathException {
XProcRuntime runtime = tl_runtime.get();
XStep step = runtime.getXProcData().getStep();
// FIXME: this can't be the best way to do this...
@@ -95,9 +95,9 @@ private void readSource() {
selector.setContextItem(doc);
Iterator iter = selector.iterator();
Iterator<XdmItem> iter = selector.iterator();
while (iter.hasNext()) {
XdmItem item = (XdmItem) iter.next();
XdmItem item = iter.next();
XdmNode node = null;
try {
node = (XdmNode) item;
@@ -140,7 +140,7 @@ public void run() throws SaxonApiException {
// Then evaluate the expression by calling iterate() on the
// net.sf.saxon.sxpath.XPathExpression object.
SequenceIterator results = xexpr.iterate(xdc);
SequenceIterator<?> results = xexpr.iterate(xdc);
// FIXME: What if the expression returns a sequence?
item = results.next();
} catch (XPathException xe) {
@@ -196,9 +196,9 @@ public void processText(XdmNode node) throws SaxonApiException {
if (parent.getNodeKind() == XdmNodeKind.ELEMENT) {
NodeInfo inode = parent.getUnderlyingNode();
InscopeNamespaceResolver inscopeNS = new InscopeNamespaceResolver(inode);
Iterator<String> prefixes = inscopeNS.iteratePrefixes();
Iterator<?> prefixes = inscopeNS.iteratePrefixes();
while (prefixes.hasNext()) {
String nspfx = prefixes.next();
String nspfx = (String)prefixes.next();
String nsuri = inscopeNS.getURIForPrefix(nspfx, true);
nsbindings.put(nspfx,nsuri);
}
@@ -75,7 +75,7 @@
private static final QName _line = new QName("line");
private static final QName _column = new QName("column");
private static final Class [] paramTypes = new Class [] {};
private static final Class<?>[] paramTypes = new Class<?>[] {};
private ReadablePipe source = null;
private ReadablePipe schemas = null;
private WritablePipe result = null;
@@ -179,7 +179,7 @@ private void runAdjacent() throws SaxonApiException {
// Then evaluate the expression by calling iterate() on the
// net.sf.saxon.sxpath.XPathExpression object.
SequenceIterator results = xexpr.iterate(xdc);
SequenceIterator<?> results = xexpr.iterate(xdc);
item = results.next();
if (item == null) {
@@ -1895,8 +1895,8 @@ private void importFunctions(XdmNode node) {
// We think this will work because we know from the test above that we're not in Saxon HE.
// It's a bit fragile, but I can't think of a better way.
Class pc = Class.forName("com.saxonica.config.ProfessionalConfiguration");
Class fc = Class.forName("net.sf.saxon.functions.FunctionLibrary");
Class<?> pc = Class.forName("com.saxonica.config.ProfessionalConfiguration");
Class<?> fc = Class.forName("net.sf.saxon.functions.FunctionLibrary");
Method setBinder = pc.getMethod("setExtensionBinder", String.class, fc);
setBinder.invoke(processor.getUnderlyingConfiguration(), "xmlcalabash" + importCount, fl);
importCount++;
@@ -607,9 +607,9 @@ protected RuntimeValue computeValue(ComputableValue var) {
NodeInfo inode = nsbinding.getNode().getUnderlyingNode();
NamePool pool = inode.getNamePool();
InscopeNamespaceResolver inscopeNS = new InscopeNamespaceResolver(inode);
Iterator<String> pfxiter = inscopeNS.iteratePrefixes();
Iterator<?> pfxiter = inscopeNS.iteratePrefixes();
while (pfxiter.hasNext()) {
String nspfx = pfxiter.next();
String nspfx = (String)pfxiter.next();
String nsuri = inscopeNS.getURIForPrefix(nspfx, "".equals(nspfx));
lclnsBindings.put(nspfx, nsuri);
}
@@ -135,9 +135,9 @@ private void readSource() {
selector.setContextItem(doc);
Iterator iter = selector.iterator();
Iterator<XdmItem> iter = selector.iterator();
while (iter.hasNext()) {
XdmItem item = (XdmItem) iter.next();
XdmItem item = iter.next();
XdmNode node = null;
try {
node = (XdmNode) item;
@@ -3,6 +3,7 @@
import net.sf.saxon.lib.CollectionURIResolver;
import net.sf.saxon.trans.XPathException;
import net.sf.saxon.expr.XPathContext;
import net.sf.saxon.om.NodeInfo;
import net.sf.saxon.om.SequenceIterator;
import net.sf.saxon.om.Item;
import net.sf.saxon.s9api.XdmNode;
@@ -34,14 +35,14 @@ public CollectionResolver(XProcRuntime runtime, Vector<XdmNode> docs, Collection
this.chainedResolver = chainedResolver;
}
public SequenceIterator resolve(String href, String base, XPathContext context) throws XPathException {
public SequenceIterator<?> resolve(String href, String base, XPathContext context) throws XPathException {
runtime.finest(null, null, "Collection: " + href + " (" + base + ")");
if (href == null) {
Item[] array = new Item[docs.size()];
for (int pos = 0; pos < docs.size(); pos++) {
array[pos] = docs.get(pos).getUnderlyingNode();
}
return new ArrayIterator(array);
return new ArrayIterator<Item>(array);
} else {
try {
URI hrefuri;
@@ -57,7 +58,7 @@ public SequenceIterator resolve(String href, String base, XPathContext context)
for (int pos = 0; pos < docs.size(); pos++) {
items[pos] = docs.get(pos).getUnderlyingNode();
}
return new ArrayIterator(items);
return new ArrayIterator<Item>(items);
}
} catch (URISyntaxException use) {
runtime.finest(null, null, "URI Syntax exception resolving collection URI: " + href + " (" + base + ")");
Oops, something went wrong.

0 comments on commit 00b04cd

Please sign in to comment.