-
Notifications
You must be signed in to change notification settings - Fork 402
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This commit updates the Saxon-HE dependency to version 11.4. It refactors the Saxon-related code as follows: - update the function+registration code to the latest API changes - extract the Saxon schema reader factory (used by Jing) in its own class - the Saxon schema reader factory is made available to Jing via the SPI mechanism (declared in `META-INF/services/com.thaiopensource.validate.SchemaReaderFactory`). This notably allows Jing to find and use our factory for both Schematron and NVDL. - the Saxon schema reader factory no longer extends Jing's `NewSaxonSchemaReaderFactory`, which set the feature "XSLT_VERSION" to "2.0" and caused a Warning to be issued by Saxon 11. Fix #1341
- Loading branch information
Showing
8 changed files
with
91 additions
and
104 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
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
55 changes: 55 additions & 0 deletions
55
src/main/java/org/idpf/epubcheck/util/saxon/SaxonSchemaReaderFactory.java
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,55 @@ | ||
package org.idpf.epubcheck.util.saxon; | ||
|
||
import javax.xml.transform.TransformerFactory; | ||
|
||
import com.thaiopensource.validate.schematron.SchematronSchemaReaderFactory; | ||
|
||
import net.sf.saxon.Configuration; | ||
import net.sf.saxon.TransformerFactoryImpl; | ||
import net.sf.saxon.lib.ErrorReporter; | ||
import net.sf.saxon.lib.FeatureKeys; | ||
import net.sf.saxon.s9api.XmlProcessingError; | ||
import net.sf.saxon.sxpath.IndependentContext; | ||
import net.sf.saxon.sxpath.XPathStaticContext; | ||
import net.sf.saxon.trans.SymbolicName; | ||
|
||
public class SaxonSchemaReaderFactory extends SchematronSchemaReaderFactory | ||
{ | ||
public void initTransformerFactory(TransformerFactory factory) | ||
{ | ||
super.initTransformerFactory(factory); | ||
factory.setAttribute(FeatureKeys.LINE_NUMBERING, Boolean.TRUE); | ||
SymbolicName.F lineNumberFn = new SymbolicName.F(LineNumberFunction.QNAME, 0); | ||
SymbolicName.F columnNumberFn = new SymbolicName.F(ColumnNumberFunction.QNAME, 0); | ||
SymbolicName.F systemIdFn = new SymbolicName.F(SystemIdFunction.QNAME, 0); | ||
if (factory instanceof TransformerFactoryImpl) | ||
{ | ||
Configuration configuration = ((TransformerFactoryImpl) factory).getConfiguration(); | ||
configuration.setErrorReporterFactory(config -> { | ||
return new ErrorReporter() | ||
{ | ||
|
||
@Override | ||
public void report(XmlProcessingError error) | ||
{ | ||
System.out.println(error.getMessage()); | ||
|
||
} | ||
}; | ||
}); | ||
XPathStaticContext xpathContext = new IndependentContext(configuration); | ||
if (!xpathContext.getFunctionLibrary().isAvailable(lineNumberFn, 20)) | ||
{ | ||
configuration.registerExtensionFunction(new LineNumberFunction()); | ||
} | ||
if (!xpathContext.getFunctionLibrary().isAvailable(columnNumberFn, 20)) | ||
{ | ||
configuration.registerExtensionFunction(new ColumnNumberFunction()); | ||
} | ||
if (!xpathContext.getFunctionLibrary().isAvailable(systemIdFn, 20)) | ||
{ | ||
configuration.registerExtensionFunction(new SystemIdFunction()); | ||
} | ||
} | ||
} | ||
} |
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
1 change: 1 addition & 0 deletions
1
src/main/resources/META-INF/services/com.thaiopensource.validate.SchemaReaderFactory
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 @@ | ||
org.idpf.epubcheck.util.saxon.SaxonSchemaReaderFactory |