Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Bump net.sf.saxon:Saxon-HE from 9.9.1-7 to 12.3" #733

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ POSSIBILITY OF SUCH DAMAGE.
<dependency>
<groupId>net.sf.saxon</groupId>
<artifactId>Saxon-HE</artifactId>
<version>12.3</version>
<version>9.9.1-7</version>
</dependency>
<dependency>
<groupId>commons-cli</groupId>
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/gov/nasa/pds/tools/label/LabelValidator.java
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
import gov.nasa.pds.tools.validate.TargetExaminer;
import gov.nasa.pds.tools.validate.ValidationProblem;
import gov.nasa.pds.validate.constants.Constants;
import net.sf.saxon.om.TreeInfo;
import net.sf.saxon.om.DocumentInfo;
import net.sf.saxon.trans.XPathException;

/**
Expand Down Expand Up @@ -252,7 +252,7 @@ public void setCatalogs(String[] catalogFiles) {
resolver.setPreferPublic(true);
resolver.setCatalogList(catalogFiles);
useLabelSchematron = true;
LOG.debug("setCatalogs:catalogFiles {}", (Object[])catalogFiles);
LOG.debug("setCatalogs:catalogFiles {}", catalogFiles);
LOG.debug("setCatalogs:useLabelSchematron explitly set to true");
}

Expand Down Expand Up @@ -658,9 +658,9 @@ public synchronized Document parseAndValidate(ProblemHandler handler, URL url)

SAXSource saxSource = new SAXSource(Utility.getInputSourceByURL(url));
saxSource.setSystemId(url.toString());
TreeInfo docInfo = LabelParser.parse(saxSource);
DocumentInfo docInfo = LabelParser.parse(saxSource);
for (DocumentValidator dv : documentValidators) {
dv.validate(handler, docInfo.getRootNode());
dv.validate(handler, docInfo);
}
}
}
Expand Down
12 changes: 6 additions & 6 deletions src/main/java/gov/nasa/pds/tools/util/LabelParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import javax.xml.transform.TransformerException;
import net.sf.saxon.Configuration;
import net.sf.saxon.lib.ParseOptions;
import net.sf.saxon.om.TreeInfo;
import net.sf.saxon.om.DocumentInfo;
import net.sf.saxon.xpath.XPathEvaluator;

public class LabelParser {
Expand All @@ -29,15 +29,15 @@ public class LabelParser {
* @return a DocumentInfo object.
* @throws TransformerException
*/
public static TreeInfo parse(Source source) throws TransformerException {
public static DocumentInfo parse(Source source) throws TransformerException {
XPathEvaluator xpath = new XPathEvaluator();
Configuration configuration = xpath.getConfiguration();
configuration.setLineNumbering(true);
configuration.setXIncludeAware(Utility.supportXincludes());
ParseOptions options = new ParseOptions();
options.withErrorHandler(new XMLErrorListener());
options.withLineNumbering(true);
options.withXIncludeAware(Utility.supportXincludes());
return configuration.buildDocumentTree(source, options);
options.setErrorListener(new XMLErrorListener());
options.setLineNumbering(true);
options.setXIncludeAware(Utility.supportXincludes());
return configuration.buildDocument(source, options);
}
}
20 changes: 1 addition & 19 deletions src/main/java/gov/nasa/pds/tools/util/XMLErrorListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,14 @@

import javax.xml.transform.ErrorListener;
import javax.xml.transform.TransformerException;
import org.xml.sax.ErrorHandler;
import org.xml.sax.SAXException;
import org.xml.sax.SAXParseException;

/**
* Class that handles errors while parsing an XML file.
*
* @author mcayanan
*
*/
public class XMLErrorListener implements ErrorListener,ErrorHandler {
public class XMLErrorListener implements ErrorListener {

/**
* Method is called when an error is encountered.
Expand Down Expand Up @@ -64,19 +61,4 @@ public void warning(TransformerException exception) throws TransformerException
throw new TransformerException(exception);
}

@Override
public void warning(SAXParseException exception) throws SAXException {
throw exception;
}

@Override
public void error(SAXParseException exception) throws SAXException {
throw exception;
}

@Override
public void fatalError(SAXParseException exception) throws SAXException {
throw exception;
}

}
15 changes: 7 additions & 8 deletions src/main/java/gov/nasa/pds/tools/util/XMLExtractor.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import org.xml.sax.InputSource;
import net.sf.saxon.Configuration;
import net.sf.saxon.lib.ParseOptions;
import net.sf.saxon.om.NamespaceUri;
import net.sf.saxon.om.TreeInfo;
import net.sf.saxon.trans.XPathException;
import net.sf.saxon.tree.tiny.TinyNodeImpl;
Expand Down Expand Up @@ -67,7 +66,7 @@ public XMLExtractor(Source xml) throws XPathExpressionException, XPathException
configuration.setLineNumbering(true);
configuration.setXIncludeAware(Utility.supportXincludes());
String definedNamespace = getValueFromDoc("namespace-uri(/*)");
xpath.getStaticContext().setDefaultElementNamespace(NamespaceUri.of (definedNamespace));
xpath.getStaticContext().setDefaultElementNamespace(definedNamespace);
}

/**
Expand All @@ -84,11 +83,11 @@ public XMLExtractor(URL url) throws XPathException, XPathExpressionException {
configuration.setLineNumbering(true);
configuration.setXIncludeAware(Utility.supportXincludes());
ParseOptions options = new ParseOptions();
options.withErrorHandler(new XMLErrorListener());
options.setErrorListener(new XMLErrorListener());
try {
xml = configuration.buildDocumentTree(new SAXSource(Utility.getInputSourceByURL(url)), options).getRootNode();
xml = configuration.buildDocument(new SAXSource(Utility.getInputSourceByURL(url)), options);
String definedNamespace = getValueFromDoc("namespace-uri(/*)");
xpath.getStaticContext().setDefaultElementNamespace(NamespaceUri.of (definedNamespace));
xpath.getStaticContext().setDefaultElementNamespace(definedNamespace);
} catch (IOException io) {
throw new XPathException("Error while reading input: " + io.getMessage());
}
Expand All @@ -100,10 +99,10 @@ public XMLExtractor(InputSource source) throws XPathException, XPathExpressionEx
configuration.setLineNumbering(true);
configuration.setXIncludeAware(Utility.supportXincludes());
ParseOptions options = new ParseOptions();
options.withErrorHandler(new XMLErrorListener());
xml = configuration.buildDocumentTree(new SAXSource(source), options).getRootNode();
options.setErrorListener(new XMLErrorListener());
xml = configuration.buildDocument(new SAXSource(source), options);
String definedNamespace = getValueFromDoc("namespace-uri(/*)");
xpath.getStaticContext().setDefaultElementNamespace(NamespaceUri.of(definedNamespace));
xpath.getStaticContext().setDefaultElementNamespace(definedNamespace);
}

public XMLExtractor(File file)
Expand Down
14 changes: 7 additions & 7 deletions src/main/java/gov/nasa/pds/tools/validate/TargetExaminer.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import gov.nasa.pds.tools.util.LabelParser;
import gov.nasa.pds.tools.util.Utility;
import gov.nasa.pds.tools.util.XMLExtractor;
import net.sf.saxon.om.TreeInfo;
import net.sf.saxon.om.DocumentInfo;
import net.sf.saxon.tree.tiny.TinyNodeImpl;

/**
Expand Down Expand Up @@ -127,11 +127,11 @@ private static boolean tagMatches(URL url, String tagCheck, boolean ignoreErrors
InputSource source = Utility.getInputSourceByURL(url);
SAXSource saxSource = new SAXSource(source);
saxSource.setSystemId(url.toString());
TreeInfo docInfo = LabelParser.parse(saxSource); // Parses a label.
DocumentInfo docInfo = LabelParser.parse(saxSource); // Parses a label.
LOG.debug("tagMatches:docInfo {},{}", docInfo, docInfo.getClass());
List<TinyNodeImpl> xmlModels = new ArrayList<>();
try {
XMLExtractor extractor = new XMLExtractor(docInfo.getRootNode());
XMLExtractor extractor = new XMLExtractor(docInfo);
xmlModels = extractor.getNodesFromDoc(tagCheck);
LOG.debug("tagMatches:url,tagCheck,xmlModels.size() {},{},{}", url, tagCheck,
xmlModels.size());
Expand Down Expand Up @@ -181,11 +181,11 @@ public static ArrayList<String> getTargetContent(URL url, String nodeCheck, Stri
InputSource source = Utility.getInputSourceByURL(url);
SAXSource saxSource = new SAXSource(source);
saxSource.setSystemId(url.toString());
TreeInfo docInfo = LabelParser.parse(saxSource); // Parses a label.
DocumentInfo docInfo = LabelParser.parse(saxSource); // Parses a label.
LOG.debug("getTargetContent:docInfo {},{}", docInfo, docInfo.getClass());
List<TinyNodeImpl> xmlModels = new ArrayList<>();
try {
XMLExtractor extractor = new XMLExtractor(docInfo.getRootNode());
XMLExtractor extractor = new XMLExtractor(docInfo);
xmlModels = extractor.getNodesFromDoc(nodeCheck);
LOG.debug("getTargetContent:url,nodeCheck,xmlModels.size() {},{},{}", url, nodeCheck,
xmlModels.size());
Expand Down Expand Up @@ -226,10 +226,10 @@ public static boolean isTargetALabel(URL url) {
InputSource source = Utility.getInputSourceByURL(url);
SAXSource saxSource = new SAXSource(source);
saxSource.setSystemId(url.toString());
TreeInfo docInfo = LabelParser.parse(saxSource); // Parses a label.
DocumentInfo docInfo = LabelParser.parse(saxSource); // Parses a label.
@SuppressWarnings("unused")
List<TinyNodeImpl> xmlModels = new ArrayList<>();
XMLExtractor extractor = new XMLExtractor(docInfo.getRootNode());
XMLExtractor extractor = new XMLExtractor(docInfo);
xmlModels = extractor.getNodesFromDoc("logical_identifier");
return true;
} catch (Throwable t) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@
import gov.nasa.pds.tools.validate.content.AudioVideo;
import gov.nasa.pds.tools.validate.rule.AbstractValidationRule;
import gov.nasa.pds.tools.validate.rule.ValidationTest;
import net.sf.saxon.om.NodeInfo;
import net.sf.saxon.om.TreeInfo;
import net.sf.saxon.om.DocumentInfo;
import net.sf.saxon.tree.tiny.TinyNodeImpl;

/**
Expand Down Expand Up @@ -112,9 +111,9 @@ public void validateFileReferences() {
DOMSource source = new DOMSource(label);
source.setSystemId(uri.toString());
try {
TreeInfo xml = LabelParser.parse(source);
DocumentInfo xml = LabelParser.parse(source);
LOG.debug("FileReferenceValidationRule:validateFileReferences:uri {}", uri);
validate(xml.getRootNode());
validate(xml);
} catch (TransformerException te) {
ProblemDefinition pd =
new ProblemDefinition(ExceptionType.ERROR, ProblemType.INTERNAL_ERROR, te.getMessage());
Expand Down Expand Up @@ -154,7 +153,7 @@ private void checkExtension(String filename, String encoding) {
}
}

private boolean validate(NodeInfo xml) {
private boolean validate(DocumentInfo xml) {
this.target = new ValidationTarget(getTarget());

try {
Expand Down