diff --git a/ph-schematron-api/pom.xml b/ph-schematron-api/pom.xml
index 6ba1913ee..f8e880bab 100644
--- a/ph-schematron-api/pom.xml
+++ b/ph-schematron-api/pom.xml
@@ -66,6 +66,10 @@
com.helger
ph-jaxb
+
+ com.helger.xsd
+ ph-xsds-xml
+
net.sf.saxon
@@ -127,6 +131,7 @@ osgi.serviceloader; filter:="(osgi.serviceloader=com.helger.schematron.svrl.ISVR
svrl.xsd
+ ${basedir}/src/main/jaxb/catalog.txt
${project.build.directory}/generated-sources/svrl
${project.build.directory}/stale/.stale-svrl
@@ -134,6 +139,7 @@ osgi.serviceloader; filter:="(osgi.serviceloader=com.helger.schematron.svrl.ISVR
true
+ false
-no-header
-Xph-default-locale
@@ -149,6 +155,12 @@ osgi.serviceloader; filter:="(osgi.serviceloader=com.helger.schematron.svrl.ISVR
-Xph-csu
-Xph-cloneable2
+
+
+ com.helger.xsd
+ ph-xsds-xml
+
+
diff --git a/ph-schematron-api/src/main/java/com/helger/schematron/svrl/CSVRL.java b/ph-schematron-api/src/main/java/com/helger/schematron/svrl/CSVRL.java
index 6da4bea7c..4c1344a99 100644
--- a/ph-schematron-api/src/main/java/com/helger/schematron/svrl/CSVRL.java
+++ b/ph-schematron-api/src/main/java/com/helger/schematron/svrl/CSVRL.java
@@ -25,6 +25,7 @@
import com.helger.commons.annotation.PresentForCodeCoverage;
import com.helger.commons.collection.impl.CommonsArrayList;
import com.helger.commons.io.resource.ClassPathResource;
+import com.helger.xsds.xml.CXML_XSD;
/**
* SVRL constants.
@@ -44,8 +45,9 @@ private static ClassLoader _getCL ()
public static final String SVRL_XSD_PATH = "schemas/svrl.xsd";
@CodingStyleguideUnaware
- public static final List SVRL_XSDS = new CommonsArrayList <> (new ClassPathResource (SVRL_XSD_PATH,
- _getCL ())).getAsUnmodifiable ();
+ public static final List SVRL_XSDS = new CommonsArrayList <> (CXML_XSD.getXSDResource (),
+ new ClassPathResource (SVRL_XSD_PATH, _getCL ()))
+ .getAsUnmodifiable ();
/** Path to the SVRL RelaxNG Compact file within the class path */
public static final String SVRL_RNC_PATH = "schemas/svrl.rnc";
diff --git a/ph-schematron-api/src/main/java/com/helger/schematron/svrl/SVRLFailedAssert.java b/ph-schematron-api/src/main/java/com/helger/schematron/svrl/SVRLFailedAssert.java
index ed17c9486..a68f2a294 100644
--- a/ph-schematron-api/src/main/java/com/helger/schematron/svrl/SVRLFailedAssert.java
+++ b/ph-schematron-api/src/main/java/com/helger/schematron/svrl/SVRLFailedAssert.java
@@ -47,9 +47,9 @@ public SVRLFailedAssert (@Nonnull final FailedAssert aFailedAssert,
@Nonnull final Function super FailedAssert, String> aLocationProvider,
@Nonnull final Function super FailedAssert, ? extends IErrorLevel> aErrLevelProvider)
{
- super (aFailedAssert.getDiagnosticReference (),
+ super (SVRLHelper.getAllDiagnosticReferences (aFailedAssert),
aFailedAssert.getId (),
- SVRLHelper.getAsString (aFailedAssert.getText ()),
+ SVRLHelper.getAsString (SVRLHelper.getText (aFailedAssert)),
aLocationProvider.apply (aFailedAssert),
aFailedAssert.getTest (),
aFailedAssert.getRole (),
diff --git a/ph-schematron-api/src/main/java/com/helger/schematron/svrl/SVRLHelper.java b/ph-schematron-api/src/main/java/com/helger/schematron/svrl/SVRLHelper.java
index 854b79697..b0776d9d7 100644
--- a/ph-schematron-api/src/main/java/com/helger/schematron/svrl/SVRLHelper.java
+++ b/ph-schematron-api/src/main/java/com/helger/schematron/svrl/SVRLHelper.java
@@ -25,13 +25,16 @@
import com.helger.commons.ValueEnforcer;
import com.helger.commons.annotation.PresentForCodeCoverage;
import com.helger.commons.annotation.ReturnsMutableCopy;
+import com.helger.commons.collection.CollectionHelper;
import com.helger.commons.collection.impl.CommonsArrayList;
import com.helger.commons.collection.impl.ICommonsList;
import com.helger.commons.concurrent.SimpleReadWriteLock;
import com.helger.commons.error.level.IErrorLevel;
import com.helger.commons.regex.RegExHelper;
import com.helger.commons.string.StringHelper;
+import com.helger.schematron.svrl.jaxb.DiagnosticReference;
import com.helger.schematron.svrl.jaxb.FailedAssert;
+import com.helger.schematron.svrl.jaxb.PropertyReference;
import com.helger.schematron.svrl.jaxb.SchematronOutputType;
import com.helger.schematron.svrl.jaxb.SuccessfulReport;
import com.helger.schematron.svrl.jaxb.Text;
@@ -264,4 +267,48 @@ public static String getBeautifiedLocation (@Nonnull final String sLocation)
}
return sResult;
}
+
+ @Nonnull
+ public static ICommonsList getAllDiagnosticReferences (@Nonnull final FailedAssert aFA)
+ {
+ return CommonsArrayList.createFiltered (aFA.getDiagnosticReferenceOrPropertyReferenceOrText (),
+ x -> x instanceof DiagnosticReference,
+ (final Object x) -> (DiagnosticReference) x);
+ }
+
+ @Nonnull
+ public static ICommonsList getAllPropertyReferences (@Nonnull final FailedAssert aFA)
+ {
+ return CommonsArrayList.createFiltered (aFA.getDiagnosticReferenceOrPropertyReferenceOrText (),
+ x -> x instanceof PropertyReference,
+ (final Object x) -> (PropertyReference) x);
+ }
+
+ @Nonnull
+ public static Text getText (@Nonnull final FailedAssert aFA)
+ {
+ return CollectionHelper.findFirstMapped (aFA.getDiagnosticReferenceOrPropertyReferenceOrText (), x -> x instanceof Text, x -> (Text) x);
+ }
+
+ @Nonnull
+ public static ICommonsList getAllDiagnosticReferences (@Nonnull final SuccessfulReport aSR)
+ {
+ return CommonsArrayList.createFiltered (aSR.getDiagnosticReferenceOrPropertyReferenceOrText (),
+ x -> x instanceof DiagnosticReference,
+ (final Object x) -> (DiagnosticReference) x);
+ }
+
+ @Nonnull
+ public static ICommonsList getAllPropertyReferences (@Nonnull final SuccessfulReport aSR)
+ {
+ return CommonsArrayList.createFiltered (aSR.getDiagnosticReferenceOrPropertyReferenceOrText (),
+ x -> x instanceof PropertyReference,
+ (final Object x) -> (PropertyReference) x);
+ }
+
+ @Nonnull
+ public static Text getText (@Nonnull final SuccessfulReport aSR)
+ {
+ return CollectionHelper.findFirstMapped (aSR.getDiagnosticReferenceOrPropertyReferenceOrText (), x -> x instanceof Text, x -> (Text) x);
+ }
}
diff --git a/ph-schematron-api/src/main/java/com/helger/schematron/svrl/SVRLSuccessfulReport.java b/ph-schematron-api/src/main/java/com/helger/schematron/svrl/SVRLSuccessfulReport.java
index 0d27755d2..88117b782 100644
--- a/ph-schematron-api/src/main/java/com/helger/schematron/svrl/SVRLSuccessfulReport.java
+++ b/ph-schematron-api/src/main/java/com/helger/schematron/svrl/SVRLSuccessfulReport.java
@@ -47,9 +47,9 @@ public SVRLSuccessfulReport (@Nonnull final SuccessfulReport aSuccessfulReport,
@Nonnull final Function super SuccessfulReport, String> aLocationProvider,
@Nonnull final Function super SuccessfulReport, ? extends IErrorLevel> aErrLevelProvider)
{
- super (aSuccessfulReport.getDiagnosticReference (),
+ super (SVRLHelper.getAllDiagnosticReferences (aSuccessfulReport),
aSuccessfulReport.getId (),
- SVRLHelper.getAsString (aSuccessfulReport.getText ()),
+ SVRLHelper.getAsString (SVRLHelper.getText (aSuccessfulReport)),
aLocationProvider.apply (aSuccessfulReport),
aSuccessfulReport.getTest (),
aSuccessfulReport.getRole (),
diff --git a/ph-schematron-api/src/main/jaxb/catalog.txt b/ph-schematron-api/src/main/jaxb/catalog.txt
new file mode 100644
index 000000000..ea8c80173
--- /dev/null
+++ b/ph-schematron-api/src/main/jaxb/catalog.txt
@@ -0,0 +1 @@
+PUBLIC "http://www.w3.org/XML/1998/namespace" "maven:com.helger.xsd:ph-xsds-xml:jar::!/schemas/xml.xsd"
diff --git a/ph-schematron-api/src/main/resources/schemas/svrl.xsd b/ph-schematron-api/src/main/resources/schemas/svrl.xsd
index 05f5d58d7..87477d0d5 100644
--- a/ph-schematron-api/src/main/resources/schemas/svrl.xsd
+++ b/ph-schematron-api/src/main/resources/schemas/svrl.xsd
@@ -11,6 +11,9 @@
-->
+
+
+
@@ -75,33 +78,35 @@
-
+
-
+
+
-
-
-
+
+
+
-
+
-
-
-
+
+
+
-
+
+
diff --git a/ph-schematron-pure/src/main/java/com/helger/schematron/pure/validation/xpath/PSXPathValidationHandlerSVRL.java b/ph-schematron-pure/src/main/java/com/helger/schematron/pure/validation/xpath/PSXPathValidationHandlerSVRL.java
index c1bb05596..a017fbd9b 100644
--- a/ph-schematron-pure/src/main/java/com/helger/schematron/pure/validation/xpath/PSXPathValidationHandlerSVRL.java
+++ b/ph-schematron-pure/src/main/java/com/helger/schematron/pure/validation/xpath/PSXPathValidationHandlerSVRL.java
@@ -287,7 +287,7 @@ private Text _getErrorText (@Nonnull final List aBoundCont
* @throws SchematronValidationException
*/
private void _handleDiagnosticReferences (@Nullable final List aSrcDiagnostics,
- @Nonnull final List aDstList,
+ @Nonnull final List super DiagnosticReference> aDstList,
@Nonnull final PSXPathBoundAssertReport aBoundAssertReport,
@Nonnull final Node aRuleMatchingNode) throws SchematronValidationException
{
@@ -306,7 +306,7 @@ private void _handleDiagnosticReferences (@Nullable final List aSrcDiag
// Create the SVRL diagnostic-reference element
final DiagnosticReference aDR = new DiagnosticReference ();
aDR.setDiagnostic (sDiagnosticID);
- aDR.setText (_getErrorText (aDiagnostic.getAllBoundContentElements (), aRuleMatchingNode));
+ aDR.getContent ().add (_getErrorText (aDiagnostic.getAllBoundContentElements (), aRuleMatchingNode));
aDstList.add (aDR);
}
}
@@ -341,9 +341,10 @@ public EContinue onFailedAssert (@Nonnull final PSAssertReport aAssertReport,
if (aAssertReport.hasLinkable ())
aFailedAssert.setRole (aAssertReport.getLinkable ().getRole ());
aFailedAssert.setTest (sTestExpression);
- aFailedAssert.setText (_getErrorText (aBoundAssertReport.getAllBoundContentElements (), aRuleMatchingNode));
+ aFailedAssert.getDiagnosticReferenceOrPropertyReferenceOrText ()
+ .add (_getErrorText (aBoundAssertReport.getAllBoundContentElements (), aRuleMatchingNode));
_handleDiagnosticReferences (aAssertReport.getAllDiagnostics (),
- aFailedAssert.getDiagnosticReference (),
+ aFailedAssert.getDiagnosticReferenceOrPropertyReferenceOrText (),
aBoundAssertReport,
aRuleMatchingNode);
m_aSchematronOutput.addActivePatternAndFiredRuleAndFailedAssert (aFailedAssert);
@@ -369,9 +370,10 @@ public EContinue onSuccessfulReport (@Nonnull final PSAssertReport aAssertReport
if (aAssertReport.hasLinkable ())
aSuccessfulReport.setRole (aAssertReport.getLinkable ().getRole ());
aSuccessfulReport.setTest (sTestExpression);
- aSuccessfulReport.setText (_getErrorText (aBoundAssertReport.getAllBoundContentElements (), aRuleMatchingNode));
+ aSuccessfulReport.getDiagnosticReferenceOrPropertyReferenceOrText ()
+ .add (_getErrorText (aBoundAssertReport.getAllBoundContentElements (), aRuleMatchingNode));
_handleDiagnosticReferences (aAssertReport.getAllDiagnostics (),
- aSuccessfulReport.getDiagnosticReference (),
+ aSuccessfulReport.getDiagnosticReferenceOrPropertyReferenceOrText (),
aBoundAssertReport,
aRuleMatchingNode);
m_aSchematronOutput.addActivePatternAndFiredRuleAndFailedAssert (aSuccessfulReport);
diff --git a/ph-schematron-pure/src/test/java/com/helger/schematron/pure/supplementary/Issue016Test.java b/ph-schematron-pure/src/test/java/com/helger/schematron/pure/supplementary/Issue016Test.java
index 3d59bac4e..ef8129baa 100644
--- a/ph-schematron-pure/src/test/java/com/helger/schematron/pure/supplementary/Issue016Test.java
+++ b/ph-schematron-pure/src/test/java/com/helger/schematron/pure/supplementary/Issue016Test.java
@@ -137,7 +137,7 @@ public void testIssue16 () throws Exception
for (final DiagnosticReference diagnisticRef : diagnisticReferences)
{
System.out.println ("Diag ref: " + diagnisticRef.getDiagnostic ());
- System.out.println ("Diag text: " + diagnisticRef.getText ());
+ System.out.println ("Diag text: " + diagnisticRef.getContentAtIndex (0));
}
}
diff --git a/ph-schematron-xslt/src/test/java/com/helger/schematron/supplementary/Issue085Test.java b/ph-schematron-xslt/src/test/java/com/helger/schematron/supplementary/Issue085Test.java
new file mode 100644
index 000000000..126f36b52
--- /dev/null
+++ b/ph-schematron-xslt/src/test/java/com/helger/schematron/supplementary/Issue085Test.java
@@ -0,0 +1,55 @@
+/**
+ * Copyright (C) 2014-2020 Philip Helger (www.helger.com)
+ * philip[at]helger[dot]com
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.helger.schematron.supplementary;
+
+import static org.junit.Assert.assertNotNull;
+
+import java.io.File;
+
+import javax.annotation.Nonnull;
+
+import org.junit.Test;
+
+import com.helger.commons.io.resource.FileSystemResource;
+import com.helger.schematron.sch.SchematronResourceSCH;
+import com.helger.schematron.svrl.SVRLMarshaller;
+import com.helger.schematron.svrl.jaxb.SchematronOutputType;
+import com.helger.xml.serialize.write.XMLWriter;
+
+public final class Issue085Test
+{
+ @Test
+ public void testIssue () throws Exception
+ {
+ validateAndProduceSVRL (new File ("src/test/resources/issues/github85/schematron.sch"),
+ new File ("src/test/resources/issues/github85/test.xml"));
+ }
+
+ public static void validateAndProduceSVRL (@Nonnull final File aSchematron, final File aXML) throws Exception
+ {
+ final SchematronResourceSCH aSCH = SchematronResourceSCH.fromFile (aSchematron);
+
+ if (false)
+ System.out.println (XMLWriter.getNodeAsString (aSCH.getXSLTProvider ().getXSLTDocument ()));
+
+ // Perform validation
+ final SchematronOutputType aSVRL = aSCH.applySchematronValidationToSVRL (new FileSystemResource (aXML));
+ assertNotNull (aSVRL);
+ if (false)
+ System.out.println (new SVRLMarshaller ().getAsString (aSVRL));
+ }
+}
diff --git a/ph-schematron-xslt/src/test/resources/issues/github85/schematron.sch b/ph-schematron-xslt/src/test/resources/issues/github85/schematron.sch
new file mode 100644
index 000000000..c3b68457e
--- /dev/null
+++ b/ph-schematron-xslt/src/test/resources/issues/github85/schematron.sch
@@ -0,0 +1,15 @@
+
+
+ ISO schematron validation file for descriptive extended constraints
+
+
+
+
+
+
+
+ Foobar
+
+
+
\ No newline at end of file
diff --git a/ph-schematron-xslt/src/test/resources/issues/github85/test.xml b/ph-schematron-xslt/src/test/resources/issues/github85/test.xml
new file mode 100644
index 000000000..cf7830ea0
--- /dev/null
+++ b/ph-schematron-xslt/src/test/resources/issues/github85/test.xml
@@ -0,0 +1,20 @@
+
+
+
+ abc
+
+ 12345
+
+
+
+ 12345
+
+
+
+
+ abc
+
+
+
+
+
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index f60f29268..cfda4700c 100644
--- a/pom.xml
+++ b/pom.xml
@@ -82,6 +82,13 @@
pom
import
+
+ com.helger.xsd
+ ph-xsds-parent-pom
+ 2.4.1
+ pom
+ import
+
net.sf.saxon
Saxon-HE