mirror of
https://github.com/itplr-kosit/validator.git
synced 2026-05-25 16:55:39 +00:00
https://github.com/itplr-kosit/validator/issues/56 trim namespaces and other strings when reading the scenarios
This commit is contained in:
parent
9838508f41
commit
ef1ce56f2a
4 changed files with 42 additions and 5 deletions
|
|
@ -47,6 +47,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||||
import de.kosit.validationtool.api.ResolvingConfigurationStrategy;
|
import de.kosit.validationtool.api.ResolvingConfigurationStrategy;
|
||||||
import de.kosit.validationtool.impl.Scenario.Transformation;
|
import de.kosit.validationtool.impl.Scenario.Transformation;
|
||||||
import de.kosit.validationtool.impl.xml.RelativeUriResolver;
|
import de.kosit.validationtool.impl.xml.RelativeUriResolver;
|
||||||
|
import de.kosit.validationtool.impl.xml.StringTrimAdapter;
|
||||||
import de.kosit.validationtool.model.scenarios.NamespaceType;
|
import de.kosit.validationtool.model.scenarios.NamespaceType;
|
||||||
import de.kosit.validationtool.model.scenarios.ResourceType;
|
import de.kosit.validationtool.model.scenarios.ResourceType;
|
||||||
import de.kosit.validationtool.model.scenarios.ScenarioType;
|
import de.kosit.validationtool.model.scenarios.ScenarioType;
|
||||||
|
|
@ -284,13 +285,13 @@ public class ContentRepository {
|
||||||
|
|
||||||
public XPathExecutable createMatchExecutable(final ScenarioType s) {
|
public XPathExecutable createMatchExecutable(final ScenarioType s) {
|
||||||
final Map<String, String> namespaces = s.getNamespace().stream()
|
final Map<String, String> namespaces = s.getNamespace().stream()
|
||||||
.collect(Collectors.toMap(NamespaceType::getPrefix, NamespaceType::getValue));
|
.collect(Collectors.toMap(NamespaceType::getPrefix, ns -> StringTrimAdapter.trim(ns.getValue())));
|
||||||
return createXPath(s.getMatch(), namespaces);
|
return createXPath(s.getMatch(), namespaces);
|
||||||
}
|
}
|
||||||
|
|
||||||
public XPathExecutable createAccepptExecutable(final ScenarioType s) {
|
public XPathExecutable createAccepptExecutable(final ScenarioType s) {
|
||||||
final Map<String, String> namespaces = s.getNamespace().stream()
|
final Map<String, String> namespaces = s.getNamespace().stream()
|
||||||
.collect(Collectors.toMap(NamespaceType::getPrefix, NamespaceType::getValue));
|
.collect(Collectors.toMap(NamespaceType::getPrefix, ns -> StringTrimAdapter.trim(ns.getValue())));
|
||||||
return createXPath(s.getAcceptMatch(), namespaces);
|
return createXPath(s.getAcceptMatch(), namespaces);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,29 @@
|
||||||
|
package de.kosit.validationtool.impl.xml;
|
||||||
|
|
||||||
|
import javax.xml.bind.annotation.adapters.XmlAdapter;
|
||||||
|
|
||||||
|
public class StringTrimAdapter extends XmlAdapter<String, String> {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String unmarshal(final String v) {
|
||||||
|
if (v == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return v.trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String marshal(final String v) {
|
||||||
|
if (v == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return v.trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String trim(final String v) {
|
||||||
|
if (v == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return v.trim();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -26,7 +26,12 @@
|
||||||
jaxb:extensionBindingPrefixes="inheritance"
|
jaxb:extensionBindingPrefixes="inheritance"
|
||||||
version="2.1">
|
version="2.1">
|
||||||
<jaxb:globalBindings>
|
<jaxb:globalBindings>
|
||||||
<xjc:serializable uid="-1"/>
|
<xjc:serializable uid="-1" />
|
||||||
|
<xjc:javaType
|
||||||
|
name="java.lang.String"
|
||||||
|
xmlType="xs:string"
|
||||||
|
adapter="de.kosit.validationtool.impl.xml.StringTrimAdapter" />
|
||||||
|
|
||||||
</jaxb:globalBindings>
|
</jaxb:globalBindings>
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -31,8 +31,10 @@
|
||||||
<description>
|
<description>
|
||||||
<p>Nur Schemaprüfung.</p>
|
<p>Nur Schemaprüfung.</p>
|
||||||
</description>
|
</description>
|
||||||
<namespace prefix="cri">http://www.xoev.de/de/validator/framework/1/createreportinput</namespace>
|
<namespace prefix="cri">http://www.xoev.de/de/validator/framework/1/createreportinput
|
||||||
<namespace prefix="test">http://validator.kosit.de/test-sample</namespace>
|
</namespace>
|
||||||
|
<namespace prefix="test">
|
||||||
|
http://validator.kosit.de/test-sample</namespace>
|
||||||
<namespace prefix="rpt">http://validator.kosit.de/test-report</namespace>
|
<namespace prefix="rpt">http://validator.kosit.de/test-report</namespace>
|
||||||
<match>/test:simple</match>
|
<match>/test:simple</match>
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue