• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

pkiraly / metadata-qa-api / #717

28 Aug 2025 09:15AM UTC coverage: 86.426% (-0.1%) from 86.526%
#717

push

pkiraly
Add priorityOnFail

12 of 23 new or added lines in 4 files covered. (52.17%)

3 existing lines in 2 files now uncovered.

5654 of 6542 relevant lines covered (86.43%)

0.86 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

94.44
/src/main/java/de/gwdg/metadataqa/api/xml/XpathEngineFactory.java
1
package de.gwdg.metadataqa.api.xml;
2

3
import org.apache.ws.commons.util.NamespaceContextImpl;
4

5
import javax.xml.namespace.NamespaceContext;
6
import javax.xml.xpath.XPath;
7
import javax.xml.xpath.XPathFactory;
8
import java.util.LinkedHashMap;
9
import java.util.Map;
10

11
public class XpathEngineFactory {
×
12

13
  private static final Map<String, String> defaultNamespaces = new LinkedHashMap<>();
1✔
14
  static {
15
    defaultNamespaces.put("xsi", "http://www.w3.org/2001/XMLSchema-instance");
1✔
16
    defaultNamespaces.put("rdf", "http://www.w3.org/1999/02/22-rdf-syntax-ns#");
1✔
17
    defaultNamespaces.put("dc", "http://purl.org/dc/elements/1.1/");
1✔
18
    defaultNamespaces.put("dcterms", "http://purl.org/dc/terms/");
1✔
19
    defaultNamespaces.put("edm", "http://www.europeana.eu/schemas/edm/");
1✔
20
    defaultNamespaces.put("owl", "http://www.w3.org/2002/07/owl#");
1✔
21
    defaultNamespaces.put("wgs84_pos", "http://www.w3.org/2003/01/geo/wgs84_pos#");
1✔
22
    defaultNamespaces.put("skos", "http://www.w3.org/2004/02/skos/core#");
1✔
23
    defaultNamespaces.put("rdaGr2", "http://rdvocab.info/ElementsGr2/");
1✔
24
    defaultNamespaces.put("foaf", "http://xmlns.com/foaf/0.1/");
1✔
25
    defaultNamespaces.put("ebucore", "http://www.ebu.ch/metadata/ontologies/ebucore/ebucore#");
1✔
26
    defaultNamespaces.put("doap", "http://usefulinc.com/ns/doap#");
1✔
27
    defaultNamespaces.put("odrl", "http://www.w3.org/ns/odrl/2/");
1✔
28
    defaultNamespaces.put("cc", "http://creativecommons.org/ns#");
1✔
29
    defaultNamespaces.put("ore", "http://www.openarchives.org/ore/terms/");
1✔
30
    defaultNamespaces.put("svcs", "http://rdfs.org/sioc/services#");
1✔
31
    defaultNamespaces.put("oa", "http://www.w3.org/ns/oa#");
1✔
32
    defaultNamespaces.put("dqv", "http://www.w3.org/ns/dqv#");
1✔
33
    defaultNamespaces.put("xml", "http://www.w3.org/XML/1998/namespace");
1✔
34
    defaultNamespaces.put("oai", "http://www.openarchives.org/OAI/2.0/");
1✔
35
    defaultNamespaces.put("lido", "http://www.lido-schema.org");
1✔
36
  }
1✔
37

38
  public static XPath initializeEngine() {
UNCOV
39
    return initializeEngine(null);
×
40
  }
41

42
  public static XPath initializeEngine(Map<String, String> customNamespaces) {
43
    var xPathfactory = XPathFactory.newInstance();
1✔
44
    XPath xpathEngine = xPathfactory.newXPath();
1✔
45
    xpathEngine.setNamespaceContext(createNamespaceContext(customNamespaces));
1✔
46
    return xpathEngine;
1✔
47
  }
48

49
  private static NamespaceContext createNamespaceContext(Map<String, String> customNamespaces) {
50
    var nsContext = new NamespaceContextImpl();
1✔
51
    for (Map.Entry<String, String> entry : defaultNamespaces.entrySet())
1✔
52
      nsContext.startPrefixMapping(entry.getKey(), entry.getValue());
1✔
53

54
    if (customNamespaces != null && !customNamespaces.isEmpty())
1✔
55
      for (Map.Entry<String, String> entry : customNamespaces.entrySet())
1✔
56
        nsContext.startPrefixMapping(entry.getKey(), entry.getValue());
1✔
57
    return nsContext;
1✔
58
  }
59
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc