From 2ccca1815104efcb826d5ead2226a36df048df68 Mon Sep 17 00:00:00 2001 From: Twan Goosen Date: Tue, 24 Nov 2020 10:53:59 +0100 Subject: [PATCH] added a class with constants for a number of namespaces --- .../java/eu/clarin/cmdi/CmdNamespaces.java | 41 +++++++++++++++++++ .../eu/clarin/cmd/toolkit/TestCMDToolkit.java | 5 ++- 2 files changed, 44 insertions(+), 2 deletions(-) create mode 100644 src/main/java/eu/clarin/cmdi/CmdNamespaces.java diff --git a/src/main/java/eu/clarin/cmdi/CmdNamespaces.java b/src/main/java/eu/clarin/cmdi/CmdNamespaces.java new file mode 100644 index 0000000..0a1c247 --- /dev/null +++ b/src/main/java/eu/clarin/cmdi/CmdNamespaces.java @@ -0,0 +1,41 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package eu.clarin.cmdi; + +/** + * + * @author Twan Goosen + */ +public final class CmdNamespaces { + + /** + * Common namespace for the CMDI record envelope + */ + public final static String CMD_RECORD_ENVELOPE_NS = "http://www.clarin.eu/cmd/1"; + + /** + * Namespace for cues for tools in a CMDI profile or component specification + */ + public final static String CMD_SPEC_CUES_NS = "http://www.clarin.eu/cmd/cues/1"; + + /** + * Namespace for schematron rules in schemata + */ + public final static String SCHEMATRON_NS = "http://purl.oclc.org/dsdl/schematron"; + + private final static String CMD_PROFIL_NS_BASE = "http://www.clarin.eu/cmd/1/profiles/"; + + /** + * + * @param profileId profile to get the namespace for + * @return the namespace for the payload for a record for the specified + * profile + */ + public final static String getCmdRecordPayloadNamespace(String profileId) { + return CMD_PROFIL_NS_BASE + profileId; + } + +} diff --git a/src/test/java/eu/clarin/cmd/toolkit/TestCMDToolkit.java b/src/test/java/eu/clarin/cmd/toolkit/TestCMDToolkit.java index b1c84c6..43a2bcb 100644 --- a/src/test/java/eu/clarin/cmd/toolkit/TestCMDToolkit.java +++ b/src/test/java/eu/clarin/cmd/toolkit/TestCMDToolkit.java @@ -4,6 +4,7 @@ */ package eu.clarin.cmd.toolkit; +import eu.clarin.cmdi.CmdNamespaces; import eu.clarin.cmdi.toolkit.CMDToolkit; import java.io.IOException; import java.io.OutputStream; @@ -107,8 +108,8 @@ protected boolean xPathCompiler(Document doc, String xpath, String profileId) th XPathCompiler xpc = SaxonUtils.getProcessor().newXPathCompiler(); xpc.declareNamespace("xs","http://www.w3.org/2001/XMLSchema"); - xpc.declareNamespace("cmd","http://www.clarin.eu/cmd/1"); - if(profileId != null) xpc.declareNamespace("cmdp", "http://www.clarin.eu/cmd/1/profiles/" + profileId); + xpc.declareNamespace("cmd",CmdNamespaces.CMD_RECORD_ENVELOPE_NS); + if(profileId != null) xpc.declareNamespace("cmdp", CmdNamespaces.getCmdRecordPayloadNamespace(profileId)); XPathExecutable xpe = xpc.compile(xpath); XPathSelector xps = xpe.load();