diff --git a/pom.xml b/pom.xml index aec521f5f..7a3452f8f 100644 --- a/pom.xml +++ b/pom.xml @@ -18,8 +18,6 @@ 2.8.9 4.5.13 2.10.377 - 10.6 - 2.12.1 com.octosign.whitelabel.ui.Main @@ -79,19 +77,38 @@ ${apache.httpcomponents.version} - net.sf.saxon - Saxon-HE - ${saxon.version} + org.junit.jupiter + junit-jupiter + 5.9.0 + test + + + org.apache.maven.plugins + maven-surefire-plugin + 3.0.0-M7 + maven-plugin - xerces - xercesImpl - ${xerces.version} + net.sf.saxon + Saxon-HE + 11.4 + + + ${project.basedir}/src/test/resources + + + + + org.apache.maven.plugins + maven-surefire-plugin + 3.0.0-M7 + + org.apache.maven.plugins maven-compiler-plugin @@ -108,7 +125,7 @@ org.codehaus.mojo - versions-maven-plugin + versions-maven-plugin 2.9.0 @@ -186,7 +203,8 @@ https://cdn.jsdelivr.net/npm/pdfjs-dist@${pdfjs.version} cmaps - ${project.resources[0].directory}/com/octosign/whitelabel/ui/vendor/pdfjs/cmaps + ${project.resources[0].directory}/com/octosign/whitelabel/ui/vendor/pdfjs/cmaps + @@ -308,13 +326,18 @@ 3.0.0 bash - ${project.build.scriptSourceDirectory}${file.separator}resources + ${project.build.scriptSourceDirectory}${file.separator}resources + ${project.build.scriptSourceDirectory}${file.separator}package.sh ${jlink.jdk.path}${file.separator}bin${file.separator}jpackage - ${project.build.directory}${file.separator}${project.artifactId}-${project.version}-${platform} + + ${project.build.directory}${file.separator}${project.artifactId}-${project.version}-${platform} + ${project.build.directory}${file.separator}preparedJDK - ${project.basedir}${file.separator}src${file.separator}main${file.separator}resources${file.separator}com${file.separator}octosign${file.separator}whitelabel + + ${project.basedir}${file.separator}src${file.separator}main${file.separator}resources${file.separator}com${file.separator}octosign${file.separator}whitelabel + ${platform} ${project.version} ${project.build.directory} diff --git a/src/main/java/com/octosign/whitelabel/communication/document/XMLDocument.java b/src/main/java/com/octosign/whitelabel/communication/document/XMLDocument.java index 8c4bd021a..a3ea1f7aa 100644 --- a/src/main/java/com/octosign/whitelabel/communication/document/XMLDocument.java +++ b/src/main/java/com/octosign/whitelabel/communication/document/XMLDocument.java @@ -25,11 +25,6 @@ public XMLDocument(Document document) { super(document); } - static { - System.setProperty("javax.xml.parsers.SAXParserFactory", "org.apache.xerces.jaxp.SAXParserFactoryImpl"); - System.setProperty("javax.xml.transform.TransformerFactory", "net.sf.saxon.TransformerFactoryImpl"); - } - public String getTransformed(String transformation) { if (isNullOrBlank(transformation)) throw new IntegrationException(Code.MISSING_INPUT, "body.parameters.transformation missing!"); diff --git a/src/main/java/com/octosign/whitelabel/preprocessing/XDCTransformer.java b/src/main/java/com/octosign/whitelabel/preprocessing/XDCTransformer.java index 4129c35ad..5174f8e09 100644 --- a/src/main/java/com/octosign/whitelabel/preprocessing/XDCTransformer.java +++ b/src/main/java/com/octosign/whitelabel/preprocessing/XDCTransformer.java @@ -152,24 +152,21 @@ private String getDocumentContent() throws TransformerException { var xmlSource = new DOMSource(document); var outputTarget = new StreamResult(new StringWriter()); - var transformerFactory= TransformerFactory.newInstance(); + var transformerFactory = TransformerFactory.newInstance(); transformerFactory.newTransformer().transform(xmlSource, outputTarget); return outputTarget.getWriter().toString(); } private Element createXMLDataContainer() { - var element = document.createElement("XMLDataContainer"); + var element = document.createElementNS(containerXmlns, "XMLDataContainer"); element.setAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns:xsd", "http://www.w3.org/2001/XMLSchema"); element.setAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance"); - if (containerXmlns != null) - element.setAttribute("xmlns", containerXmlns); - return element; } private Element createXMLData() { - var element = document.createElement("XMLData"); + var element = document.createElementNS(containerXmlns, "XMLData"); element.setAttribute("ContentType", "application/xml; charset=UTF-8"); element.setAttribute("Identifier", identifierUri); element.setAttribute("Version", identifierVersion); @@ -178,7 +175,7 @@ private Element createXMLData() { } private Element createUsedSchemasReferenced() { - var element = document.createElement("UsedSchemasReferenced"); + var element = document.createElementNS(containerXmlns, "UsedSchemasReferenced"); if (isPresent(xsdSchema) || isPresent(xsltSchema)) { var documentXmlnsNode = document.getFirstChild().getAttributes().getNamedItem("xmlns"); if (documentXmlnsNode != null) @@ -224,7 +221,7 @@ private static String toURIString(String xmlns, String suffix) { } private Element createUsedXSDReference() { - var element = document.createElement("UsedXSDReference"); + var element = document.createElementNS(containerXmlns,"UsedXSDReference"); element.setAttribute("TransformAlgorithm", canonicalizationMethod); element.setAttribute("DigestMethod", toNamespacedString(digestAlgorithm)); element.setAttribute("DigestValue", computeDigest(xsdSchema)); @@ -234,7 +231,7 @@ private Element createUsedXSDReference() { } private Element createUsedPresentationSchemaReference() { - var element = document.createElement("UsedPresentationSchemaReference"); + var element = document.createElementNS(containerXmlns, "UsedPresentationSchemaReference"); element.setAttribute("TransformAlgorithm", canonicalizationMethod); element.setAttribute("DigestMethod", toNamespacedString(digestAlgorithm)); element.setAttribute("DigestValue", computeDigest(xsltSchema)); diff --git a/src/test/java/com/octosign/whitelabel/communication/document/XMLDocumentTest.java b/src/test/java/com/octosign/whitelabel/communication/document/XMLDocumentTest.java new file mode 100644 index 000000000..bf4e102b8 --- /dev/null +++ b/src/test/java/com/octosign/whitelabel/communication/document/XMLDocumentTest.java @@ -0,0 +1,21 @@ +package com.octosign.whitelabel.communication.document; + +import org.apache.commons.io.IOUtils; +import org.junit.jupiter.api.Test; + +import java.io.IOException; + +import static org.junit.jupiter.api.Assertions.*; + +class XMLDocumentTest { + @Test + void testTransformsPlainHtmlWithoutAddingNamespaces() throws IOException { + var input = this.getClass().getResourceAsStream("abc.xml").readAllBytes(); + var transformation = new String(this.getClass().getResourceAsStream("abc.xslt").readAllBytes()); + + XMLDocument doc = new XMLDocument(new Document("id1", "test.xml", input)); + String transformed = doc.getTransformed(transformation); + + assertEquals(-1, transformed.lastIndexOf(":p>")); + } +} diff --git a/src/test/resources/com/octosign/whitelabel/communication/document/abc.xml b/src/test/resources/com/octosign/whitelabel/communication/document/abc.xml new file mode 100644 index 000000000..66434cb16 --- /dev/null +++ b/src/test/resources/com/octosign/whitelabel/communication/document/abc.xml @@ -0,0 +1,9 @@ + + + + +

Úrad pre dohľad nad zdravotnou starostlivosťou, právny odbor (ďalej len „úrad“), ako orgán príslušný na vydanie povolenia podľa § 18 ods. 1 písm. u) zákona č. 581/2004 Z.z. o zdravotných poisťovniach, dohľade nad zdravotnou starostlivosťou a o zmene a doplnení niektorých zákonov v znení neskorších predpisov (ďalej len „zákon č. 581/2004 Z.z.“), § 11 ods. 3 a § 21 ods. 1 zákona č. 578/2004 Z.z. o poskytovateľoch zdravotnej starostlivosti, zdravotníckych pracovníkoch, stavovských organizáciách v zdravotníctve a o zmene a doplnení niektorých zákonov v znení neskorších predpisov (ďalej len „zákon č. 578/2004 Z.z.“) a § 5 a § 6 ods. 2 zákona č. 71/1967 Zb. o správnom konaní (správny poriadok) v znení neskorších predpisov (ďalej len „Správny poriadok“) v súlade s § 46 a § 47 Správneho poriadku a § 25 ods. 1 zákona č. 578/2004 Z.z. rozhodol t a k t o:

+

Na základe žiadosti zo dňa XXXXXXX žiadateľa XXXXXXX, XXXXX, právna forma spoločnosť s ručením obmedzeným, IČO: XXXXX, zastúpenej štatutárnym orgánom XXXXXXXXXX (ďalej len „žiadateľ“) o vydanie povolenia na prevádzkovanie ambulancie záchrannej zdravotnej služby (ďalej len „ZZS“), a to ambulancie XXXXXXX v sídle stanice XXXXXX, podľa § 18 ods. 1 písm. u) zákona č. 581/2004 Z.z., § 11 ods. 3 písm. d), § 21 ods. 1 zákona č. 578/2004 Z.z. v súlade s § 12 ods. 4 a 5, § 14 ods. 11 a § 15 ods. 1 a 2 zákona č. 578/2004 Z.z.

+
+
+
\ No newline at end of file diff --git a/src/test/resources/com/octosign/whitelabel/communication/document/abc.xslt b/src/test/resources/com/octosign/whitelabel/communication/document/abc.xslt new file mode 100644 index 000000000..01afbd25e --- /dev/null +++ b/src/test/resources/com/octosign/whitelabel/communication/document/abc.xslt @@ -0,0 +1,223 @@ + + + + http://www.w3.org/1999/xhtml + + + <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> + + + + + + + +
+ +
+ +
+
+
+ + +
+ + <br/> + + + + + + + + + , + + + + + + + + + <br/> + + + <br/> + + <br/> + + + + + + , + + + + + + +   + + + + + + + + + + + + +   + + + / + + + + + +   + + + + + + + + + + + + + + + + + + + + + + + pt + + + + + + + + + + + table-border + + + + + + + + + + + + + + + + + + + + . + + . + + + + { + + } + + + + + + / + + + + + + + + . + + + + januára + + + februára + + + marca + + + apríla + + + mája + + + júna + + + júla + + + augusta + + + septembra + + + októbra + + + novembra + + + decembra + + +   + + + + { + + } + + + + + + + + + +