Skip to content

Commit

Permalink
added a class with constants for a number of namespaces
Browse files Browse the repository at this point in the history
  • Loading branch information
twagoo committed Dec 3, 2020
1 parent fbdeb93 commit 2ccca18
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 2 deletions.
41 changes: 41 additions & 0 deletions src/main/java/eu/clarin/cmdi/CmdNamespaces.java
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>
*/
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;
}

}
5 changes: 3 additions & 2 deletions src/test/java/eu/clarin/cmd/toolkit/TestCMDToolkit.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit 2ccca18

Please sign in to comment.