mirror of
https://github.com/itplr-kosit/validator.git
synced 2026-05-25 16:55:39 +00:00
more tests
This commit is contained in:
parent
7dc62012a6
commit
01ae592862
3 changed files with 129 additions and 12 deletions
|
|
@ -13,7 +13,6 @@ import org.apache.commons.lang3.StringUtils;
|
|||
|
||||
import lombok.AccessLevel;
|
||||
import lombok.Data;
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
|
@ -42,9 +41,15 @@ class XPathBuilder implements Builder<XPathExecutable> {
|
|||
private XPathExecutable executable;
|
||||
|
||||
@Setter(AccessLevel.PACKAGE)
|
||||
@Getter(AccessLevel.PACKAGE)
|
||||
private Map<String, String> namespaces;
|
||||
|
||||
Map<String, String> getNamespaces() {
|
||||
if (this.namespaces == null) {
|
||||
this.namespaces = new HashMap<>();
|
||||
}
|
||||
return this.namespaces;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the xpath expression.
|
||||
*
|
||||
|
|
@ -66,7 +71,7 @@ class XPathBuilder implements Builder<XPathExecutable> {
|
|||
}
|
||||
try {
|
||||
if (this.executable == null) {
|
||||
this.executable = repository.createXPath(this.xpath, this.namespaces);
|
||||
this.executable = repository.createXPath(this.xpath, getNamespaces());
|
||||
} else {
|
||||
this.xpath = extractExpression();
|
||||
extractNamespaces();
|
||||
|
|
@ -81,19 +86,15 @@ class XPathBuilder implements Builder<XPathExecutable> {
|
|||
}
|
||||
|
||||
private void extractNamespaces() {
|
||||
if (this.namespaces == null) {
|
||||
this.namespaces = new HashMap<>();
|
||||
}
|
||||
|
||||
final Map<String, String> ns = new HashMap<>();
|
||||
final Iterator<String> iterator = this.executable.getUnderlyingExpression().getInternalExpression().getRetainedStaticContext()
|
||||
.iteratePrefixes();
|
||||
final Iterable<String> iterable = () -> iterator;
|
||||
StreamSupport.stream(iterable.spliterator(), false).filter(e -> !ArrayUtils.contains(IGNORED_PREFIXES, e))
|
||||
.filter(StringUtils::isNotBlank).forEach(e -> {
|
||||
ns.put(e, this.executable.getUnderlyingExpression().getInternalExpression().getRetainedStaticContext()
|
||||
.getURIForPrefix(e, false));
|
||||
});
|
||||
this.namespaces.putAll(ns);
|
||||
.filter(StringUtils::isNotBlank).forEach(e -> ns.put(e, this.executable.getUnderlyingExpression().getInternalExpression()
|
||||
.getRetainedStaticContext().getURIForPrefix(e, false)));
|
||||
getNamespaces().putAll(ns);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -143,7 +143,7 @@ public class ContentRepository {
|
|||
throw new IllegalStateException("Can not compile xslt executable for uri " + uri, e);
|
||||
} finally {
|
||||
if (!listener.hasErrors() && listener.hasEvents()) {
|
||||
log.warn("Received warnings while loading a xslt script {}", uri);
|
||||
log.warn("Received warnings or errors while loading a xslt script {}", uri);
|
||||
listener.getErrors().forEach(e -> e.log(log));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue