Commit 745f70ac authored by Dr. Martin Goik's avatar Dr. Martin Goik

Fixing schema version related flaw

parent ca2d60c1
......@@ -13,7 +13,6 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<oxygenxml.version>21.1.0.0</oxygenxml.version>
</properties>
<repositories>
......@@ -22,39 +21,11 @@
<id>hdm-mi-internal-maven-repo</id>
<url>https://maven.mi.hdm-stuttgart.de/nexus/repository/mi-maven</url>
</repository>
<repository>
<id>oxygenxml-repo</id>
<url>https://maven.mi.hdm-stuttgart.de/nexus/repository/oxygen</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>com.oxygenxml</groupId>
<artifactId>oxygen-patched-xerces</artifactId>
<version>${oxygenxml.version}</version>
</dependency>
<dependency>
<groupId>com.oxygenxml</groupId>
<artifactId>oxygen</artifactId>
<version>${oxygenxml.version}</version>
</dependency>
<!-- Still needed to keep oxygenxml happy using legacy logging -->
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
<dependency>
<groupId>com.rackspace.eclipse.webtools.sourceediting</groupId>
<artifactId>org.eclipse.wst.xml.xpath2.processor</artifactId>
<version>2.1.100</version>
</dependency>
<dependency>
<groupId>postgresql</groupId>
<artifactId>postgresql</artifactId>
......@@ -74,20 +45,6 @@
<version>2.10.0</version>
</dependency>
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.3.1</version>
</dependency>
<!-- Required for executable jar generation to avoid ClassNotFoundException:
com.fasterxml.jackson.core.type.TypeReference and similar dependency problems. -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.9.8</version>
</dependency>
<dependency>
<groupId>org.jdom</groupId>
<artifactId>jdom2</artifactId>
......@@ -103,7 +60,7 @@
<dependency>
<groupId>de.hdm_stuttgart.mi.exam</groupId>
<artifactId>unitmarking</artifactId>
<version>1.0</version>
<version>1.1</version>
</dependency>
</dependencies>
......@@ -142,7 +99,6 @@
<javadocExecutable>${java.home}/bin/javadoc</javadocExecutable>
</configuration>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.2.0</version>
......
......@@ -13,7 +13,6 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<oxygenxml.version>21.1.0.0</oxygenxml.version>
</properties>
<repositories>
......@@ -22,39 +21,11 @@
<id>hdm-mi-internal-maven-repo</id>
<url>https://maven.mi.hdm-stuttgart.de/nexus/repository/mi-maven</url>
</repository>
<repository>
<id>oxygenxml-repo</id>
<url>https://maven.mi.hdm-stuttgart.de/nexus/repository/oxygen</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>com.oxygenxml</groupId>
<artifactId>oxygen-patched-xerces</artifactId>
<version>${oxygenxml.version}</version>
</dependency>
<dependency>
<groupId>com.oxygenxml</groupId>
<artifactId>oxygen</artifactId>
<version>${oxygenxml.version}</version>
</dependency>
<!-- Still needed to keep oxygenxml happy using legacy logging -->
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
<dependency>
<groupId>com.rackspace.eclipse.webtools.sourceediting</groupId>
<artifactId>org.eclipse.wst.xml.xpath2.processor</artifactId>
<version>2.1.100</version>
</dependency>
<dependency>
<groupId>postgresql</groupId>
<artifactId>postgresql</artifactId>
......@@ -74,20 +45,6 @@
<version>2.10.0</version>
</dependency>
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.3.1</version>
</dependency>
<!-- Required for executable jar generation to avoid ClassNotFoundException:
com.fasterxml.jackson.core.type.TypeReference and similar dependency problems. -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.9.8</version>
</dependency>
<dependency>
<groupId>org.jdom</groupId>
<artifactId>jdom2</artifactId>
......@@ -103,7 +60,7 @@
<dependency>
<groupId>de.hdm_stuttgart.mi.exam</groupId>
<artifactId>unitmarking</artifactId>
<version>1.0</version>
<version>1.1</version>
</dependency>
</dependencies>
......
......@@ -13,7 +13,6 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<oxygenxml.version>21.1.0.0</oxygenxml.version>
</properties>
<repositories>
......@@ -22,39 +21,10 @@
<id>hdm-mi-internal-maven-repo</id>
<url>https://maven.mi.hdm-stuttgart.de/nexus/repository/mi-maven</url>
</repository>
<repository>
<id>oxygenxml-repo</id>
<url>https://maven.mi.hdm-stuttgart.de/nexus/repository/oxygen</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>com.oxygenxml</groupId>
<artifactId>oxygen-patched-xerces</artifactId>
<version>${oxygenxml.version}</version>
</dependency>
<dependency>
<groupId>com.oxygenxml</groupId>
<artifactId>oxygen</artifactId>
<version>${oxygenxml.version}</version>
</dependency>
<!-- Still needed to keep oxygenxml happy using legacy logging -->
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
<dependency>
<groupId>com.rackspace.eclipse.webtools.sourceediting</groupId>
<artifactId>org.eclipse.wst.xml.xpath2.processor</artifactId>
<version>2.1.100</version>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
......@@ -74,20 +44,6 @@
<version>2.12.0</version>
</dependency>
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.3.1</version>
</dependency>
<!-- Required for executable jar generation to avoid ClassNotFoundException:
com.fasterxml.jackson.core.type.TypeReference and similar dependency problems. -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.9.8</version>
</dependency>
<dependency>
<groupId>org.jdom</groupId>
<artifactId>jdom2</artifactId>
......@@ -103,7 +59,7 @@
<dependency>
<groupId>de.hdm_stuttgart.mi.exam</groupId>
<artifactId>unitmarking</artifactId>
<version>1.0</version>
<version>1.1</version>
</dependency>
</dependencies>
......@@ -124,50 +80,50 @@
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.1.1</version>
<configuration>
<javaApiLinks>
<property>
<name>api_11</name>
<value>https://klausur.mi.hdm-stuttgart.de/doc/openjdk-11-doc/api/</value>
</property>
</javaApiLinks>
<stylesheetfile>localstyles.css</stylesheetfile>
<additionalJOptions>
<additionalJOption>-html5</additionalJOption>
</additionalJOptions>
<javadocExecutable>${java.home}/bin/javadoc</javadocExecutable>
</configuration>
</plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.1.1</version>
<configuration>
<javaApiLinks>
<property>
<name>api_11</name>
<value>https://klausur.mi.hdm-stuttgart.de/doc/openjdk-11-doc/api/</value>
</property>
</javaApiLinks>
<stylesheetfile>localstyles.css</stylesheetfile>
<additionalJOptions>
<additionalJOption>-html5</additionalJOption>
</additionalJOptions>
<javadocExecutable>${java.home}/bin/javadoc</javadocExecutable>
</configuration>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.1.1</version>
<configuration>
<descriptors>
<descriptor>src/main/assembly/assembly.xml</descriptor>
</descriptors>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<archive>
<manifest>
<mainClass>de.hdm_stuttgart.mi.sda1.test.ex1.ShowReachedPoints</mainClass>
</manifest>
</archive>
</configuration>
</execution>
</executions>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.2.0</version>
<configuration>
<descriptors>
<descriptor>src/main/assembly/assembly.xml</descriptor>
</descriptors>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<archive>
<manifest>
<mainClass>de.hdm_stuttgart.mi.sda1.test.ex1.ShowReachedPoints</mainClass>
</manifest>
</archive>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
......
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" >
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:vc="http://www.w3.org/2007/XMLSchema-versioning" vc:minVersion="1.0" vc:maxVersion="1.1" >
<xs:element name="catalog">
<xs:complexType>
......
......@@ -13,7 +13,6 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<oxygenxml.version>21.1.0.0</oxygenxml.version>
</properties>
<repositories>
......@@ -22,39 +21,10 @@
<id>hdm-mi-internal-maven-repo</id>
<url>https://maven.mi.hdm-stuttgart.de/nexus/repository/mi-maven</url>
</repository>
<repository>
<id>oxygenxml-repo</id>
<url>https://maven.mi.hdm-stuttgart.de/nexus/repository/oxygen</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>com.oxygenxml</groupId>
<artifactId>oxygen-patched-xerces</artifactId>
<version>${oxygenxml.version}</version>
</dependency>
<dependency>
<groupId>com.oxygenxml</groupId>
<artifactId>oxygen</artifactId>
<version>${oxygenxml.version}</version>
</dependency>
<!-- Still needed to keep oxygenxml happy using legacy logging -->
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
<dependency>
<groupId>com.rackspace.eclipse.webtools.sourceediting</groupId>
<artifactId>org.eclipse.wst.xml.xpath2.processor</artifactId>
<version>2.1.100</version>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
......@@ -74,20 +44,6 @@
<version>2.12.0</version>
</dependency>
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.3.1</version>
</dependency>
<!-- Required for executable jar generation to avoid ClassNotFoundException:
com.fasterxml.jackson.core.type.TypeReference and similar dependency problems. -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.9.8</version>
</dependency>
<dependency>
<groupId>org.jdom</groupId>
<artifactId>jdom2</artifactId>
......@@ -103,7 +59,7 @@
<dependency>
<groupId>de.hdm_stuttgart.mi.exam</groupId>
<artifactId>unitmarking</artifactId>
<version>1.0</version>
<version>1.1</version>
</dependency>
</dependencies>
......
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>de.hdm_stuttgart.mi.exam</groupId>
<artifactId>unitmarking</artifactId>
<version>1.0</version>
<version>1.1</version>
<packaging>jar</packaging>
<name>unitmarking</name>
......@@ -13,7 +13,7 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<oxygenxml.version>20.1.0.3</oxygenxml.version>
<oxygenxml.version>21.1.0.2</oxygenxml.version>
</properties>
<distributionManagement>
......@@ -32,9 +32,10 @@
</repositories>
<dependencies>
<dependency>
<groupId>com.oxygenxml</groupId>
<artifactId>oxygen-xercesImpl</artifactId>
<artifactId>oxygen-patched-xerces</artifactId>
<version>${oxygenxml.version}</version>
</dependency>
......@@ -44,38 +45,19 @@
<version>${oxygenxml.version}</version>
</dependency>
<!-- Still needed to keep oxygenxml happy using legacy logging -->
<!-- Keep oxygenxml happy using legacy logging -->
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
<!-- Current log4j -->
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>2.4</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.4</version>
</dependency>
<dependency>
<groupId>com.rackspace.eclipse.webtools.sourceediting</groupId>
<artifactId>org.eclipse.wst.xml.xpath2.processor</artifactId>
<version>2.1.100</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
</dependency>
<dependency>
<groupId>org.jdom</groupId>
<artifactId>jdom2</artifactId>
......@@ -93,23 +75,23 @@
<build>
<extensions>
<extension>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-ssh-external</artifactId>
<version>2.10</version>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-ssh-external</artifactId>
<version>3.3.4</version>
</extension>
</extensions>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
\ No newline at end of file
</project>
package de.hdm_stuttgart.mi.exam.unitmarking.xml;
import org.apache.xerces.impl.Constants;
import org.junit.Assert;
import org.w3c.dom.Attr;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.xml.sax.SAXException;
import org.xml.sax.SAXParseException;
......@@ -10,14 +12,13 @@ import org.xml.sax.helpers.DefaultHandler;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamSource;
import javax.xml.validation.SchemaFactory;
import javax.xml.validation.Validator;
import java.io.IOException;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.HashMap;
import java.util.Map;
public class XmlTestSupport {
......@@ -34,15 +35,14 @@ public class XmlTestSupport {
// XMLConstants only provides W3C_XML_SCHEMA_NS_URI rather than XSD-1.1;
static private final SchemaFactory schemaFactory = SchemaFactory.newInstance(
org.apache.xerces.impl.Constants.W3C_XML_SCHEMA11_NS_URI);
private final DocumentBuilder nonValidatingBuilder;
Constants.W3C_XML_SCHEMA11_NS_URI);
private final DocumentBuilder validatingBuilder, nonValidatingBuilder;
/**
* The directory containing schema unit tests.
*/
public final String testDirectoryPathname;
/**
* Unit test support for schema unit tests.
*
......@@ -51,17 +51,24 @@ public class XmlTestSupport {
public XmlTestSupport(final String testDirectoryPathname) {
this.testDirectoryPathname = testDirectoryPathname;
final DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setNamespaceAware(true);
factory.setValidating(false);
factory.setXIncludeAware(true);
DocumentBuilder nonValidatingBuilderTmp = null;
DocumentBuilder validatingBuilderTmp = null, nonValidatingBuilderTmp = null;
try {
factory.setNamespaceAware(true);
factory.setXIncludeAware(true);
factory.setValidating(false);
nonValidatingBuilderTmp = factory.newDocumentBuilder();
nonValidatingBuilderTmp.setErrorHandler(new DefaultHandler());
factory.setValidating(true);
validatingBuilderTmp = factory.newDocumentBuilder();
validatingBuilderTmp.setErrorHandler(new DefaultHandler());
} catch (ParserConfigurationException e) {
Assert.fail("Unable to create non-validating parser:" + e);
} finally {
nonValidatingBuilder = nonValidatingBuilderTmp;
validatingBuilder = validatingBuilderTmp;
}
}
......@@ -144,17 +151,21 @@ public class XmlTestSupport {
assertExpectedValidationStatus(instanceFilename, false);
}
static void validate(final Path instancePath, final Path schemaPath, final boolean expectValidInstance) {
void validate(final Path instancePath, final Path schemaPath, final boolean expectValidInstance) {
final String instanceFilename = instancePath.getFileName().toString();
try {
// Weird: Caching validators by schema for re-use fails
// on xs:ID attributes on repeated parsing!
// So always re-create!
final Validator validator = schemaFactory.newSchema(schemaPath.toFile()).newValidator();
final Document schemaDoc = validatingBuilder.parse(schemaPath.toFile());
final Validator validator = schemaFactory.newSchema(new DOMSource(schemaDoc)).newValidator();
validator.setFeature("http://apache.org/xml/features/validation/schema", true);
validator.setFeature("http://apache.org/xml/features/validation/assert-comments-and-pi-checking", true);
validator.setFeature("http://apache.org/xml/features/validation/schema-full-checking", true);
validator.setFeature("http://apache.org/xml/features/honour-all-schemaLocations", true);
validator.validate( // Re-do parsing: Starting from DOMSource(root)
new StreamSource(instancePath.toFile())); // conceals line numbers, sigh!
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment