diff --git a/CHANGELOG.md b/CHANGELOG.md
index 5e45ded..c394c53 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -9,6 +9,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed
- date conversion when using [ConfigurationBuilder#date(Date)](https://github.com/itplr-kosit/validator/blob/d7beb1040418ae5cbeb9427532fd87482f55756c/src/main/java/de/kosit/validationtool/config/ConfigurationBuilder.java#L109)
+### Added
+- read saxon XdmNode with InputFactory
+
+### Changed
+- InputFactory has methods to read any java.xml.transform.Source as Input not only StreamSources
+- InputFactory uses a generated UUID as name for SourceInput, if no "real" name can be derived
+
## 1.3.1
### Fixed
- `getFailedAsserts()` and `isSchematronValid()` in [DefaultResult.java](https://github.com/itplr-kosit/validator/blob/master/src/main/java/de/kosit/validationtool/impl/DefaultResult.java)
diff --git a/pom.xml b/pom.xml
index 0c0651b..ca017d9 100644
--- a/pom.xml
+++ b/pom.xml
@@ -426,7 +426,7 @@
* Note: The various implementations of {@link Source} varies wether the can be read twice or no. This implementation
* tries to handle this with respect document identification (hashcode).
*
- * This class is know to work with:
+ * This class is known to work with:
*
- * Note: computing the hashcode is only supported for {@link StreamSource}. You can not directly use other {@link Source
- * Soures}. You need to supply the hashcode for identification then.
+ * Reads a test document from a {@link Source}. Note: computing the hashcode is only supported for {@link StreamSource}.
+ * You can not directly use other {@link Source Soures}. You need to supply the hashcode for identification then.
*
* @param source source
* @return an {@link Input}
*/
- public static Input read(final StreamSource source) {
- return read(source, DEFAULT_ALGORITH);
+ public static Input read(final Source source) {
+ if (source instanceof StreamSource) {
+ return read(source, source.getSystemId(), DEFAULT_ALGORITH);
+ }
+ final String name = UUID.randomUUID().toString();
+ return read(source, name, PSEUDO_NAME_ALGORITHM, name.getBytes());
}
/**
@@ -182,11 +194,16 @@ public class InputFactory {
* Soures}. You need to supply the hashcode for identification then.
*
* @param source source
- * @param digestAlgorithm the digest algorithm
+ * @param name the digest algorithm
* @return an {@link Input}
*/
- public static Input read(final StreamSource source, final String digestAlgorithm) {
- return read(source, digestAlgorithm, null);
+ public static Input read(final Source source, final String name) {
+ checkNotEmpty(name);
+ return read(source, name, PSEUDO_NAME_ALGORITHM, name.getBytes());
+ }
+
+ public static Input read(final Source source, final String name, final String digestAlgorithm) {
+ return read(source, name, digestAlgorithm, null);
}
/**
@@ -198,7 +215,12 @@ public class InputFactory {
*/
public static Input read(final Source source, final String digestAlgorithm, final byte[] hashcode) {
checkNull(source);
- return new SourceInput(source, source.getSystemId(), digestAlgorithm, hashcode);
+ return read(source, source.getSystemId(), digestAlgorithm, hashcode);
+ }
+
+ public static Input read(final Source source, final String name, final String digestAlgorithm, final byte[] hashcode) {
+ checkNull(source);
+ return new SourceInput(source, name, digestAlgorithm, hashcode);
}
/**
@@ -281,4 +303,17 @@ public class InputFactory {
return read(new StreamSource(inputStream, name), digestAlgorithm);
}
+ /**
+ * Reads a saxon {@link XdmNode} with a given name. Hashcode identification is based on the name of the supplied input.
+ * Now real hashcode is computed.
+ *
+ * @param node the node to read
+ * @param name the name of the {@link Input}
+ * @return an {@link Input} to validate
+ */
+ public static Input read(final XdmNode node, final String name) {
+ checkNull(node);
+ return new XdmNodeInput(node, name, PSEUDO_NAME_ALGORITHM, name.getBytes());
+ }
+
}
diff --git a/src/main/java/de/kosit/validationtool/api/Result.java b/src/main/java/de/kosit/validationtool/api/Result.java
index a32adb2..91617ae 100644
--- a/src/main/java/de/kosit/validationtool/api/Result.java
+++ b/src/main/java/de/kosit/validationtool/api/Result.java
@@ -9,7 +9,7 @@ import org.w3c.dom.Document;
import net.sf.saxon.s9api.XdmNode;
/**
- * API Rückgabe Objekt des Ergebnisses des Validierungsprozesses.
+ * API result object holding various information of the validation process results.
*
* @author Andreas Penski
*/
diff --git a/src/main/java/de/kosit/validationtool/daemon/Daemon.java b/src/main/java/de/kosit/validationtool/daemon/Daemon.java
index fa0dcbe..24da017 100644
--- a/src/main/java/de/kosit/validationtool/daemon/Daemon.java
+++ b/src/main/java/de/kosit/validationtool/daemon/Daemon.java
@@ -1,5 +1,6 @@
package de.kosit.validationtool.daemon;
+import static de.kosit.validationtool.impl.Printer.writeOut;
import static org.apache.commons.lang3.StringUtils.defaultIfBlank;
import java.io.IOException;
@@ -10,7 +11,6 @@ import java.util.concurrent.Executors;
import com.sun.net.httpserver.HttpHandler;
import com.sun.net.httpserver.HttpServer;
-import lombok.AccessLevel;
import lombok.RequiredArgsConstructor;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
@@ -48,7 +48,7 @@ public class Daemon {
* @param port the port to expose
* @param threadCount the number of working threads
*/
- public Daemon(String hostname, int port, int threadCount) {
+ public Daemon(final String hostname, final int port, final int threadCount) {
this.bindAddress = hostname;
this.port = port;
this.threadCount = threadCount;
@@ -73,17 +73,20 @@ public class Daemon {
server.setExecutor(createExecutor());
server.start();
log.info("Server {} started", server.getAddress());
+ if (!log.isInfoEnabled()) {
+ writeOut("Server {0} started", server.getAddress());
+ }
} catch (final IOException e) {
log.error("Error starting HttpServer for Valdidator: {}", e.getMessage(), e);
}
}
- private HttpHandler createRootHandler(Configuration config) {
- HttpHandler rootHandler;
+ private HttpHandler createRootHandler(final Configuration config) {
+ final HttpHandler rootHandler;
final DefaultCheck check = new DefaultCheck(config);
final CheckHandler checkHandler = new CheckHandler(check, config.getContentRepository().getProcessor());
- if (guiEnabled) {
- GuiHandler gui = new GuiHandler();
+ if (this.guiEnabled) {
+ final GuiHandler gui = new GuiHandler();
rootHandler = new RoutingHandler(checkHandler, gui);
} else {
rootHandler = checkHandler;
diff --git a/src/main/java/de/kosit/validationtool/impl/DefaultCheck.java b/src/main/java/de/kosit/validationtool/impl/DefaultCheck.java
index fc6a9d9..81baa2c 100644
--- a/src/main/java/de/kosit/validationtool/impl/DefaultCheck.java
+++ b/src/main/java/de/kosit/validationtool/impl/DefaultCheck.java
@@ -62,6 +62,7 @@ public class DefaultCheck implements Check {
@Getter
private final ConversionService conversionService;
+ @Getter
private final Configuration configuration;
@Getter
diff --git a/src/main/java/de/kosit/validationtool/impl/Printer.java b/src/main/java/de/kosit/validationtool/impl/Printer.java
new file mode 100644
index 0000000..3a1eb51
--- /dev/null
+++ b/src/main/java/de/kosit/validationtool/impl/Printer.java
@@ -0,0 +1,21 @@
+package de.kosit.validationtool.impl;
+
+import java.text.MessageFormat;
+
+/**
+ * Wrapper for {@link System Systems} printing capability.
+ *
+ * @author Andreas Penski
+ */
+public class Printer {
+
+ /**
+ * Writes to standard output channel.
+ *
+ * @param message the message with placeholders
+ * @param params the params.
+ */
+ public static void writeOut(final String message, final Object... params) {
+ System.out.println(MessageFormat.format(message, params));
+ }
+}
diff --git a/src/main/java/de/kosit/validationtool/impl/input/SourceInput.java b/src/main/java/de/kosit/validationtool/impl/input/SourceInput.java
index 5cd7753..637990c 100644
--- a/src/main/java/de/kosit/validationtool/impl/input/SourceInput.java
+++ b/src/main/java/de/kosit/validationtool/impl/input/SourceInput.java
@@ -1,9 +1,13 @@
package de.kosit.validationtool.impl.input;
+import static org.apache.commons.lang3.StringUtils.defaultIfBlank;
+
import java.io.IOException;
import java.nio.charset.Charset;
+import javax.xml.bind.util.JAXBSource;
import javax.xml.transform.Source;
+import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamSource;
import org.apache.commons.io.input.ReaderInputStream;
@@ -11,21 +15,23 @@ import org.apache.commons.io.input.ReaderInputStream;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;
+import net.sf.saxon.om.TreeInfo;
+
/**
- * A validator {@link de.kosit.validationtool.api.Input} based on a {@link Source}.
+ * A validator {@link de.kosit.validationtool.api.Input} based on a {@link Source}.
*
*
*
* Other {@link Source Sources} may work as well, please try and let us know.
- *
true wenn der Schritt ausgelassen werden soll
*/
default boolean isSkipped(final Bag results) {
return false;
diff --git a/src/main/java/de/kosit/validationtool/impl/tasks/DocumentParseAction.java b/src/main/java/de/kosit/validationtool/impl/tasks/DocumentParseAction.java
index c5559a7..89166a1 100644
--- a/src/main/java/de/kosit/validationtool/impl/tasks/DocumentParseAction.java
+++ b/src/main/java/de/kosit/validationtool/impl/tasks/DocumentParseAction.java
@@ -27,6 +27,7 @@ import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import de.kosit.validationtool.api.Input;
+import de.kosit.validationtool.impl.input.XdmNodeInput;
import de.kosit.validationtool.impl.model.Result;
import de.kosit.validationtool.model.reportInput.ValidationResultsWellformedness;
import de.kosit.validationtool.model.reportInput.XMLSyntaxError;
@@ -47,6 +48,7 @@ import net.sf.saxon.s9api.XdmNode;
public class DocumentParseAction implements CheckAction {
private final Processor processor;
+
/**
* Parsed und überprüft ein übergebenes Dokument darauf ob es well-formed ist. Dies stellt den ersten
* Verarbeitungsschritt des Prüf-Tools dar. Diese Funktion verzichtet explizit auf die Validierung gegenüber einem
@@ -60,11 +62,17 @@ public class DocumentParseAction implements CheckAction {
throw new IllegalArgumentException("Input may not be null");
}
Result