onvdl with saxon 8.x

Issues related with the oNVDL implementation of NVDL.
queshaw
Posts: 44
Joined: Wed Aug 08, 2007 5:56 am

onvdl with saxon 8.x

Post by queshaw »

This is really a patch suggestion rather than an issue.

I am using saxon 8.x in a java application and didn't want to also have saxon 6.x on my classpath. So, I:

1. Replaced com.icl.saxon with net.sf.saxon throughout the source.
2. Modified com/oxygenxml/validate/isoschematron/SchemaReaderImpl.java and com/thaiopensource/validate/schematron/SchemaReaderImpl.java by
a. Adding import net.sf.saxon.FeatureKeys;.
b. Replacing:
factory.setAttribute("http://icl.com/saxon/feature/linenumbering", Boolean.TRUE);
with {
factory.setAttribute("http://saxon.sf.net/feature/linenumbering", Boolean.TRUE);
factory.setAttribute(FeatureKeys.VERSION_WARNING, false);
}

Disabling the version warning about processing XSLT 1.0 with a 2.0 processor.

I suppose the jar manifest should change to use saxon 8 as well in that case.
queshaw
Posts: 44
Joined: Wed Aug 08, 2007 5:56 am

Post by queshaw »

Patch file onvdl.diff below. You would run:

patch -p1 <onvdl.diff

in the directory into which src.zip was extracted. The diff contains CRLF line endings, which might get lost if you copy and paste from the web browser.

onvdl.diff:

diff -Naur src/com/oxygenxml/validate/isoschematron/SaxonSchemaReaderFactory.java newsrc/com/oxygenxml/validate/isoschematron/SaxonSchemaReaderFactory.java
--- src/com/oxygenxml/validate/isoschematron/SaxonSchemaReaderFactory.java 2007-04-03 23:03:40.000000000 +0000
+++ newsrc/com/oxygenxml/validate/isoschematron/SaxonSchemaReaderFactory.java 2007-09-06 18:54:36.000000000 +0000
@@ -1,11 +1,12 @@
package com.oxygenxml.validate.isoschematron;

-import com.icl.saxon.TransformerFactoryImpl;
-
import javax.xml.transform.TransformerFactory;

+import net.sf.saxon.TransformerFactoryImpl;
+
public class SaxonSchemaReaderFactory extends SchematronSchemaReaderFactory {
public TransformerFactory newTransformerFactory() {
- return new TransformerFactoryImpl();
+ TransformerFactory tf = new TransformerFactoryImpl();
+ return tf;
}
}
diff -Naur src/com/oxygenxml/validate/isoschematron/SchemaReaderImpl.java newsrc/com/oxygenxml/validate/isoschematron/SchemaReaderImpl.java
--- src/com/oxygenxml/validate/isoschematron/SchemaReaderImpl.java 2007-04-03 23:26:30.000000000 +0000
+++ newsrc/com/oxygenxml/validate/isoschematron/SchemaReaderImpl.java 2007-09-06 18:54:36.000000000 +0000
@@ -17,6 +17,9 @@
import com.thaiopensource.xml.sax.DraconianErrorHandler;
import com.thaiopensource.xml.sax.ForkContentHandler;
import com.thaiopensource.xml.sax.XMLReaderCreator;
+
+import net.sf.saxon.FeatureKeys;
+
import org.xml.sax.Attributes;
import org.xml.sax.ContentHandler;
import org.xml.sax.ErrorHandler;
@@ -85,10 +88,11 @@
private void initTransformerFactory(TransformerFactory factory) {
String name = factory.getClass().getName();
try {
- if (name.equals("com.icl.saxon.TransformerFactoryImpl"))
- factory.setAttribute("http://icl.com/saxon/feature/linenumbering",
+ if (name.equals("net.sf.saxon.TransformerFactoryImpl")) {
+ factory.setAttribute("http://saxon.sf.net/feature/linenumbering",
Boolean.TRUE);
- else if (name.equals("org.apache.xalan.processor.TransformerFactoryImpl")) {
+ factory.setAttribute(FeatureKeys.VERSION_WARNING, false);
+ } else if (name.equals("org.apache.xalan.processor.TransformerFactoryImpl")) {
// Try both the documented URI and the URI that the code expects.
try {
// This is the URI that the code expects.
diff -Naur src/com/thaiopensource/validate/schematron/SaxonSchemaReaderFactory.java newsrc/com/thaiopensource/validate/schematron/SaxonSchemaReaderFactory.java
--- src/com/thaiopensource/validate/schematron/SaxonSchemaReaderFactory.java 2006-11-15 21:07:04.000000000 +0000
+++ newsrc/com/thaiopensource/validate/schematron/SaxonSchemaReaderFactory.java 2007-09-06 18:54:36.000000000 +0000
@@ -1,11 +1,12 @@
package com.thaiopensource.validate.schematron;

-import com.icl.saxon.TransformerFactoryImpl;
-
import javax.xml.transform.TransformerFactory;

+import net.sf.saxon.TransformerFactoryImpl;
+
public class SaxonSchemaReaderFactory extends SchematronSchemaReaderFactory {
public TransformerFactory newTransformerFactory() {
- return new TransformerFactoryImpl();
+ TransformerFactory tf = new TransformerFactoryImpl();
+ return tf;
}
}
diff -Naur src/com/thaiopensource/validate/schematron/SchemaReaderImpl.java newsrc/com/thaiopensource/validate/schematron/SchemaReaderImpl.java
--- src/com/thaiopensource/validate/schematron/SchemaReaderImpl.java 2007-01-16 20:24:48.000000000 +0000
+++ newsrc/com/thaiopensource/validate/schematron/SchemaReaderImpl.java 2007-09-06 18:54:36.000000000 +0000
@@ -17,6 +17,9 @@
import com.thaiopensource.xml.sax.DraconianErrorHandler;
import com.thaiopensource.xml.sax.ForkContentHandler;
import com.thaiopensource.xml.sax.XMLReaderCreator;
+
+import net.sf.saxon.FeatureKeys;
+
import org.xml.sax.Attributes;
import org.xml.sax.ContentHandler;
import org.xml.sax.ErrorHandler;
@@ -85,10 +88,11 @@
private void initTransformerFactory(TransformerFactory factory) {
String name = factory.getClass().getName();
try {
- if (name.equals("com.icl.saxon.TransformerFactoryImpl"))
- factory.setAttribute("http://icl.com/saxon/feature/linenumbering",
+ if (name.equals("net.sf.saxon.TransformerFactoryImpl")) {
+ factory.setAttribute("http://saxon.sf.net/feature/linenumbering",
Boolean.TRUE);
- else if (name.equals("org.apache.xalan.processor.TransformerFactoryImpl")) {
+ factory.setAttribute(FeatureKeys.VERSION_WARNING, false);
+ } else if (name.equals("org.apache.xalan.processor.TransformerFactoryImpl")) {
// Try both the documented URI and the URI that the code expects.
try {
// This is the URI that the code expects.
Post Reply