Skip to content

Commit d3fe9e0

Browse files
author
mgeipel
committed
closed issue #13
1 parent 46cdc34 commit d3fe9e0

File tree

8 files changed

+168
-151
lines changed

8 files changed

+168
-151
lines changed

src/main/assembly/assembly.xml

Lines changed: 63 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,64 @@
1-
<assembly>
2-
<id>bin</id>
3-
<formats>
4-
<format>zip</format>
5-
</formats>
6-
7-
<!-- Adds dependencies to zip package under lib directory -->
8-
<dependencySets>
9-
<dependencySet>
10-
<useProjectArtifact>false</useProjectArtifact>
11-
<outputDirectory>lib</outputDirectory>
12-
<unpack>false</unpack>
13-
</dependencySet>
14-
</dependencySets>
15-
16-
<fileSets>
17-
<fileSet>
18-
<directory>${project.build.scriptSourceDirectory}</directory>
19-
<outputDirectory></outputDirectory>
20-
<includes>
21-
<include>*.bat</include>
22-
<include>*.sh</include>
23-
</includes>
24-
<filtered>true</filtered>
25-
</fileSet>
26-
<!-- adds jar package to the root directory of zip package -->
27-
<fileSet>
28-
<directory>${project.build.directory}</directory>
29-
<outputDirectory></outputDirectory>
30-
<includes>
31-
<include>*.jar</include>
32-
</includes>
33-
</fileSet>
34-
35-
<fileSet>
36-
<directory>examples/</directory>
37-
<outputDirectory>examples/</outputDirectory>
38-
<includes>
39-
<include>*/*</include>
40-
</includes>
41-
</fileSet>
42-
<fileSet>
43-
<directory>modules/</directory>
44-
<outputDirectory>modules/</outputDirectory>
45-
</fileSet>
46-
</fileSets>
1+
<assembly>
2+
<id>bin</id>
3+
<formats>
4+
<format>zip</format>
5+
</formats>
6+
7+
<!-- Adds dependencies to zip package under lib directory -->
8+
<dependencySets>
9+
<dependencySet>
10+
<useProjectArtifact>false</useProjectArtifact>
11+
<outputDirectory>lib</outputDirectory>
12+
<unpack>false</unpack>
13+
</dependencySet>
14+
</dependencySets>
15+
16+
<fileSets>
17+
<fileSet>
18+
<directory>${project.build.scriptSourceDirectory}</directory>
19+
<outputDirectory></outputDirectory>
20+
<includes>
21+
<include>*.bat</include>
22+
<include>*.sh</include>
23+
</includes>
24+
<filtered>true</filtered>
25+
</fileSet>
26+
<!-- adds jar package to the root directory of zip package -->
27+
<fileSet>
28+
<directory>${project.build.directory}</directory>
29+
<outputDirectory></outputDirectory>
30+
<includes>
31+
<include>*.jar</include>
32+
</includes>
33+
</fileSet>
34+
35+
<fileSet>
36+
<directory>examples/</directory>
37+
<outputDirectory>examples/</outputDirectory>
38+
<includes>
39+
<include>*/*/*/*</include>
40+
<include>*/*/*</include>
41+
<include>*/*</include>
42+
</includes>
43+
</fileSet>
44+
<fileSet>
45+
<directory>${project.basedir}/src/main/resources/schemata/
46+
</directory>
47+
<outputDirectory>schemata/</outputDirectory>
48+
<includes>
49+
<include>*.xsd</include>
50+
</includes>
51+
</fileSet>
52+
<fileSet>
53+
<directory>modules/</directory>
54+
<outputDirectory>modules/</outputDirectory>
55+
</fileSet>
56+
<fileSet>
57+
<directory></directory>
58+
<outputDirectory></outputDirectory>
59+
<includes>
60+
<include>*.md</include>
61+
</includes>
62+
</fileSet>
63+
</fileSets>
4764
</assembly>

src/main/java/org/culturegraph/mf/morph/AbstractMetamorphDomWalker.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public String getString() {
7171
private static final String MAP = "map";
7272
private static final String MACRO = "call-macro";
7373
private static final String POSTPROCESS = "postprocess";
74-
private static final String SCHEMA_FILE = "schema/metamorph.xsd";
74+
private static final String SCHEMA_FILE = "schemata/metamorph.xsd";
7575
private static final int LOWEST_COMPATIBLE_VERSION = 1;
7676
private static final int CURRENT_VERSION = 1;
7777

@@ -117,18 +117,18 @@ public final void walk(final Reader reader) {
117117
walk(DomLoader.parse(SCHEMA_FILE, new InputSource(reader)));
118118
}
119119

120-
public void walk(final Reader morphDefReader, final Map<String, String> vars) {
120+
public final void walk(final Reader morphDefReader, final Map<String, String> vars) {
121121
this.vars.putAll(vars);
122122
walk(morphDefReader);
123123
}
124124

125125

126-
public void walk(final String morphDef, final Map<String, String> vars) {
126+
public final void walk(final String morphDef, final Map<String, String> vars) {
127127
this.vars.putAll(vars);
128128
walk(morphDef);
129129
}
130130

131-
public void walk(final InputStream inputStream, final Map<String, String> vars) {
131+
public final void walk(final InputStream inputStream, final Map<String, String> vars) {
132132
this.vars.putAll(vars);
133133
walk(inputStream);
134134
}
Lines changed: 101 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
/**
2-
*
3-
*/
1+
/**
2+
*
3+
*/
44
/*
55
* Copyright 2013 Deutsche Nationalbibliothek
66
*
@@ -16,101 +16,101 @@
1616
* See the License for the specific language governing permissions and
1717
* limitations under the License.
1818
*/
19-
package org.culturegraph.mf.test;
20-
21-
import java.io.File;
22-
import java.io.FileNotFoundException;
23-
import java.io.IOException;
24-
import java.io.InputStream;
25-
import java.net.URL;
26-
import java.util.ArrayList;
27-
import java.util.List;
28-
29-
import javax.xml.XMLConstants;
30-
import javax.xml.parsers.DocumentBuilder;
31-
import javax.xml.parsers.DocumentBuilderFactory;
32-
import javax.xml.parsers.ParserConfigurationException;
33-
import javax.xml.validation.Schema;
34-
import javax.xml.validation.SchemaFactory;
35-
36-
import org.culturegraph.mf.util.ResourceUtil;
37-
import org.w3c.dom.Document;
38-
import org.w3c.dom.Element;
39-
import org.w3c.dom.NodeList;
40-
import org.xml.sax.SAXException;
41-
42-
43-
/**
44-
* @author Christoph Böhme <[email protected]>
45-
*
46-
*/
47-
public final class TestCaseLoader {
48-
49-
/**
50-
*
51-
*/
52-
private static final String FILE_NOT_FOUND = "Could not find test case file: ";
53-
54-
private static final String SCHEMA_FILE = "schema/metamorph-test.xsd";
55-
56-
private static final String TEST_CASE_TAG = "test-case";
57-
58-
private TestCaseLoader() {
59-
// No instances allowed
60-
}
61-
62-
63-
//TODO seems to be unused
64-
public static List<TestCase> load(final String testDef) {
65-
try {
66-
return load(ResourceUtil.getStream(testDef));
67-
} catch (FileNotFoundException e) {
68-
throw new TestConfigurationException(FILE_NOT_FOUND + testDef, e);
69-
}
70-
}
71-
72-
//TODO seems to be unused
73-
public static List<TestCase> load(final File testDefFile) {
74-
try {
75-
return load(ResourceUtil.getStream(testDefFile));
76-
} catch (FileNotFoundException e) {
77-
throw new TestConfigurationException(FILE_NOT_FOUND + testDefFile, e);
78-
}
79-
}
80-
81-
public static List<TestCase> load(final InputStream inputStream) {
82-
83-
try {
84-
final SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
85-
final URL schemaUrl = Thread.currentThread().getContextClassLoader().getResource(SCHEMA_FILE);
86-
final Schema schema = schemaFactory.newSchema(schemaUrl);
87-
88-
final DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance();
89-
builderFactory.setIgnoringElementContentWhitespace(true);
90-
builderFactory.setIgnoringComments(true);
91-
builderFactory.setNamespaceAware(true);
92-
builderFactory.setCoalescing(true);
93-
builderFactory.setSchema(schema);
94-
95-
final DocumentBuilder builder = builderFactory.newDocumentBuilder();
96-
final Document doc = builder.parse(inputStream);
97-
98-
final List<TestCase> testCases = new ArrayList<TestCase>();
99-
final NodeList testCaseNodes = doc.getElementsByTagName(TEST_CASE_TAG);
100-
for(int i=0; i < testCaseNodes.getLength(); ++i) {
101-
final Element testCaseElement = (Element) testCaseNodes.item(i);
102-
testCases.add(new TestCase(testCaseElement));
103-
}
104-
105-
return testCases;
106-
107-
} catch (ParserConfigurationException e) {
108-
throw new TestConfigurationException("Parser configuration failed", e);
109-
} catch (SAXException e) {
110-
throw new TestConfigurationException("Parser error", e);
111-
} catch (IOException e) {
112-
throw new TestConfigurationException("Error while reading file", e);
113-
}
114-
}
115-
}
116-
19+
package org.culturegraph.mf.test;
20+
21+
import java.io.File;
22+
import java.io.FileNotFoundException;
23+
import java.io.IOException;
24+
import java.io.InputStream;
25+
import java.net.URL;
26+
import java.util.ArrayList;
27+
import java.util.List;
28+
29+
import javax.xml.XMLConstants;
30+
import javax.xml.parsers.DocumentBuilder;
31+
import javax.xml.parsers.DocumentBuilderFactory;
32+
import javax.xml.parsers.ParserConfigurationException;
33+
import javax.xml.validation.Schema;
34+
import javax.xml.validation.SchemaFactory;
35+
36+
import org.culturegraph.mf.util.ResourceUtil;
37+
import org.w3c.dom.Document;
38+
import org.w3c.dom.Element;
39+
import org.w3c.dom.NodeList;
40+
import org.xml.sax.SAXException;
41+
42+
43+
/**
44+
* @author Christoph Böhme <[email protected]>
45+
*
46+
*/
47+
public final class TestCaseLoader {
48+
49+
/**
50+
*
51+
*/
52+
private static final String FILE_NOT_FOUND = "Could not find test case file: ";
53+
54+
private static final String SCHEMA_FILE = "schemata/metamorph-test.xsd";
55+
56+
private static final String TEST_CASE_TAG = "test-case";
57+
58+
private TestCaseLoader() {
59+
// No instances allowed
60+
}
61+
62+
63+
//TODO seems to be unused
64+
public static List<TestCase> load(final String testDef) {
65+
try {
66+
return load(ResourceUtil.getStream(testDef));
67+
} catch (FileNotFoundException e) {
68+
throw new TestConfigurationException(FILE_NOT_FOUND + testDef, e);
69+
}
70+
}
71+
72+
//TODO seems to be unused
73+
public static List<TestCase> load(final File testDefFile) {
74+
try {
75+
return load(ResourceUtil.getStream(testDefFile));
76+
} catch (FileNotFoundException e) {
77+
throw new TestConfigurationException(FILE_NOT_FOUND + testDefFile, e);
78+
}
79+
}
80+
81+
public static List<TestCase> load(final InputStream inputStream) {
82+
83+
try {
84+
final SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
85+
final URL schemaUrl = Thread.currentThread().getContextClassLoader().getResource(SCHEMA_FILE);
86+
final Schema schema = schemaFactory.newSchema(schemaUrl);
87+
88+
final DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance();
89+
builderFactory.setIgnoringElementContentWhitespace(true);
90+
builderFactory.setIgnoringComments(true);
91+
builderFactory.setNamespaceAware(true);
92+
builderFactory.setCoalescing(true);
93+
builderFactory.setSchema(schema);
94+
95+
final DocumentBuilder builder = builderFactory.newDocumentBuilder();
96+
final Document doc = builder.parse(inputStream);
97+
98+
final List<TestCase> testCases = new ArrayList<TestCase>();
99+
final NodeList testCaseNodes = doc.getElementsByTagName(TEST_CASE_TAG);
100+
for(int i=0; i < testCaseNodes.getLength(); ++i) {
101+
final Element testCaseElement = (Element) testCaseNodes.item(i);
102+
testCases.add(new TestCase(testCaseElement));
103+
}
104+
105+
return testCases;
106+
107+
} catch (ParserConfigurationException e) {
108+
throw new TestConfigurationException("Parser configuration failed", e);
109+
} catch (SAXException e) {
110+
throw new TestConfigurationException("Parser error", e);
111+
} catch (IOException e) {
112+
throw new TestConfigurationException("Error while reading file", e);
113+
}
114+
}
115+
}
116+

0 commit comments

Comments
 (0)