diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml
index fffece1a..abbc62d8 100644
--- a/.github/workflows/maven.yml
+++ b/.github/workflows/maven.yml
@@ -13,13 +13,10 @@ jobs:
java: [ 11, 12, 13, 14, 15, 16, 17 ]
steps:
- - uses: actions/checkout@v2
- - uses: actions/setup-java@v1
+ - uses: actions/checkout@v4
+ - uses: actions/setup-java@v4
with:
+ distribution: 'zulu'
java-version: ${{ matrix.java }}
- - uses: actions/cache@v2
- with:
- path: ~/.m2
- key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
- restore-keys: ${{ runner.os }}-m2
+ cache: 'maven'
- run: mvn -B package --file pom.xml
diff --git a/README.md b/README.md
index edfd3050..783619f7 100644
--- a/README.md
+++ b/README.md
@@ -36,13 +36,13 @@ Java Class Model API for Predictive Model Markup Language (PMML).
JPMML-Model library JAR files (together with accompanying Java source and Javadocs JAR files) are released via [Maven Central Repository](https://repo1.maven.org/maven2/org/jpmml/).
-The current version is **1.6.6** (1 October, 2024).
+The current version is **1.6.7** (20 November, 2024).
```xml
org.jpmml
pmml-model
- 1.6.6
+ 1.6.7
```
diff --git a/pmml-model-gwt/pom.xml b/pmml-model-gwt/pom.xml
index b19733c8..92a0df7a 100644
--- a/pmml-model-gwt/pom.xml
+++ b/pmml-model-gwt/pom.xml
@@ -44,7 +44,7 @@
org.apache.maven.plugins
maven-dependency-plugin
- 3.8.0
+ 3.8.1
generate-sources
diff --git a/pmml-model/src/main/java/org/jpmml/model/PMMLOutputStream.java b/pmml-model/src/main/java/org/jpmml/model/PMMLOutputStream.java
index 79ec3250..48f59f85 100644
--- a/pmml-model/src/main/java/org/jpmml/model/PMMLOutputStream.java
+++ b/pmml-model/src/main/java/org/jpmml/model/PMMLOutputStream.java
@@ -64,13 +64,9 @@ public void write(int b) throws IOException {
} else
if(string.endsWith(">")){
- String updatedString = string.replace(Version.PMML_4_4.getNamespaceURI(), this.version.getNamespaceURI());
+ string = string.replace(Version.PMML_4_4.getNamespaceURI(), this.version.getNamespaceURI());
- if(Objects.equals(string, updatedString)){
- throw new IllegalStateException();
- }
-
- super.out.write(updatedString.getBytes("UTF-8"));
+ super.out.write(string.getBytes("UTF-8"));
this.buffer = null;
} else
diff --git a/pmml-model/src/main/java/org/jpmml/model/SAXUtil.java b/pmml-model/src/main/java/org/jpmml/model/SAXUtil.java
index 848c24e0..a4772c3e 100644
--- a/pmml-model/src/main/java/org/jpmml/model/SAXUtil.java
+++ b/pmml-model/src/main/java/org/jpmml/model/SAXUtil.java
@@ -3,12 +3,18 @@
*/
package org.jpmml.model;
+import java.io.IOException;
import java.io.InputStream;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
+import javax.xml.transform.Result;
+import javax.xml.transform.TransformerConfigurationException;
+import javax.xml.transform.TransformerFactory;
import javax.xml.transform.sax.SAXSource;
+import javax.xml.transform.sax.SAXTransformerFactory;
+import javax.xml.transform.sax.TransformerHandler;
import jakarta.xml.bind.JAXBException;
import org.jpmml.model.filters.CountFilter;
@@ -26,6 +32,19 @@ public class SAXUtil {
private SAXUtil(){
}
+ static
+ public void transform(InputSource source, Result result, XMLFilter... filters) throws IOException, TransformerConfigurationException, ParserConfigurationException, SAXException {
+ SAXTransformerFactory transformerFactory = (SAXTransformerFactory)TransformerFactory.newInstance();
+
+ TransformerHandler transformerHandler = transformerFactory.newTransformerHandler();
+ transformerHandler.setResult(result);
+
+ XMLReader xmlReader = SAXUtil.createFilteredReader(SAXUtil.createXMLReader(), filters);
+ xmlReader.setContentHandler(transformerHandler);
+
+ xmlReader.parse(source);
+ }
+
/**
* @see ImportFilter
* @see SkipFilter
diff --git a/pmml-model/src/test/java/org/jpmml/model/PMMLOutputStreamTest.java b/pmml-model/src/test/java/org/jpmml/model/PMMLOutputStreamTest.java
new file mode 100644
index 00000000..132372e3
--- /dev/null
+++ b/pmml-model/src/test/java/org/jpmml/model/PMMLOutputStreamTest.java
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2024 Villu Ruusmann
+ */
+package org.jpmml.model;
+
+import java.io.ByteArrayOutputStream;
+import java.io.OutputStream;
+
+import javax.xml.transform.stream.StreamResult;
+
+import org.dmg.pmml.PMML;
+import org.dmg.pmml.Version;
+import org.junit.Test;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+public class PMMLOutputStreamTest {
+
+ @Test
+ public void marshal() throws Exception {
+ PMML pmml = new PMML();
+
+ try {
+ marshal(pmml, Version.XPMML);
+
+ fail();
+ } catch(IllegalArgumentException iae){
+ // Ignored
+ }
+
+ String string = marshal(pmml, Version.PMML_4_4);
+
+ assertTrue(string.contains(Version.PMML_4_4.getNamespaceURI()));
+ assertFalse(string.contains(Version.PMML_4_3.getNamespaceURI()));
+
+ string = marshal(pmml, Version.PMML_4_3);
+
+ assertFalse(string.contains(Version.PMML_4_4.getNamespaceURI()));
+ assertTrue(string.contains(Version.PMML_4_3.getNamespaceURI()));
+ }
+
+ static
+ private String marshal(PMML pmml, Version version) throws Exception {
+ ByteArrayOutputStream buffer = new ByteArrayOutputStream();
+
+ try(OutputStream os = new PMMLOutputStream(buffer, version)){
+ JAXBUtil.marshalPMML(pmml, new StreamResult(os));
+ }
+
+ return buffer.toString("UTF-8");
+ }
+}
\ No newline at end of file
diff --git a/pmml-model/src/test/java/org/jpmml/model/SchemaUpdateTest.java b/pmml-model/src/test/java/org/jpmml/model/SchemaUpdateTest.java
index dc14771f..f115f601 100644
--- a/pmml-model/src/test/java/org/jpmml/model/SchemaUpdateTest.java
+++ b/pmml-model/src/test/java/org/jpmml/model/SchemaUpdateTest.java
@@ -10,9 +10,6 @@
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.TransformerConfigurationException;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.sax.SAXTransformerFactory;
-import javax.xml.transform.sax.TransformerHandler;
import javax.xml.transform.stream.StreamResult;
import jakarta.xml.bind.JAXBException;
@@ -42,16 +39,8 @@ public byte[] upgradeToLatest(byte[] bytes) throws IOException, ParserConfigurat
public byte[] downgrade(byte[] bytes, Version version) throws IOException, TransformerConfigurationException, ParserConfigurationException, SAXException {
ByteArrayOutputStream result = new ByteArrayOutputStream();
- SAXTransformerFactory transformerFactory = (SAXTransformerFactory)TransformerFactory.newInstance();
-
- TransformerHandler transformer = transformerFactory.newTransformerHandler();
- transformer.setResult(new StreamResult(result));
-
- ExportFilter exportFilter = new ExportFilter(SAXUtil.createXMLReader(), version);
- exportFilter.setContentHandler(transformer);
-
try(InputStream is = new ByteArrayInputStream(bytes)){
- exportFilter.parse(new InputSource(is));
+ SAXUtil.transform(new InputSource(is), new StreamResult(result), new ExportFilter(version));
}
return result.toByteArray();
diff --git a/pom.xml b/pom.xml
index 0370d7f5..fb73b72c 100644
--- a/pom.xml
+++ b/pom.xml
@@ -135,23 +135,23 @@
com.esotericsoftware
kryo
- [5.0.0, 5.6.0]
+ [5.0.0, 5.6.2]
com.fasterxml.jackson.core
jackson-annotations
- [2.11.0, 2.17.2]
+ [2.11.0, 2.18.2]
com.fasterxml.jackson.core
jackson-databind
- [2.11.0, 2.17.2]
+ [2.11.0, 2.18.2]
com.fasterxml.jackson.dataformat
jackson-dataformat-yaml
- [2.11.0, 2.17.2]
+ [2.11.0, 2.18.2]
@@ -214,7 +214,7 @@
org.apache.maven.plugins
maven-surefire-plugin
- 3.5.0
+ 3.5.2
false
@@ -265,7 +265,7 @@
org.apache.maven.plugins
maven-javadoc-plugin
- 3.10.0
+ 3.11.1
1.8
@@ -323,7 +323,7 @@
org.codehaus.mojo
versions-maven-plugin
- 2.17.1
+ 2.18.0
de.jutzig