Skip to content

Commit

Permalink
Merge branch 'develop' into fix/save-mapref-metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
jelovirt authored Jan 27, 2024
2 parents 93b2840 + b6a2db6 commit 318429b
Show file tree
Hide file tree
Showing 97 changed files with 1,384 additions and 1,015 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ def bundled = [
"dita12": "https://github.com/dita-ot/org.oasis-open.dita.v1_2/archive/1.2.1.zip",
"dita20": "https://github.com/dita-ot/dita/releases/download/2.0.0-20240115/org.oasis-open.dita.v2_0.zip",
"dita20-techcomm": "https://github.com/dita-ot/dita-techcomm/releases/download/2.0.0-20240122/org.oasis-open.dita.techcomm.v2_0.zip",
"xdita": "https://github.com/oasis-tcs/dita-lwdita/releases/download/v0.3.0.1/org.oasis-open.xdita.v0_3_0.zip",
"xdita": "https://github.com/oasis-tcs/dita-lwdita/releases/download/v0.3.0.2/org.oasis-open.xdita.v0_3_2.zip",
"index": "https://github.com/dita-ot/org.dita.index/releases/download/1.0.0/org.dita.index-1.0.0.zip",
"axf": "https://github.com/dita-ot/org.dita.pdf2.axf/releases/download/3.6.1/org.dita.pdf2.axf-3.6.1.zip",
"xep": "https://github.com/dita-ot/org.dita.pdf2.xep/releases/download/3.6.3/org.dita.pdf2.xep-3.6.3.zip",
Expand Down
38 changes: 0 additions & 38 deletions src/test/java/org/dita/dost/IntegrationTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -131,33 +131,6 @@ public void testconrefend() throws Throwable {
builder().name(Paths.get("conref", "conrefend")).transtype(PREPROCESS).input(Paths.get("range.ditamap")).test();
}

@Test
public void testmapref_topicrefID() throws Throwable {
builder()
.name(Paths.get("mapref", "mapref_topicrefID"))
.transtype(PREPROCESS)
.input(Paths.get("bookmap.ditamap"))
.test();
}

@Test
public void testmapref_to_conref() throws Throwable {
builder()
.name(Paths.get("mapref", "mapref_to_conref"))
.transtype(PREPROCESS)
.input(Paths.get("root.ditamap"))
.test();
}

@Test
public void testmapref_reltables() throws Throwable {
builder()
.name(Paths.get("mapref", "mapref_reltables"))
.transtype(PREPROCESS)
.input(Paths.get("main.ditamap"))
.test();
}

@Test
public void testcoderef_source() throws Throwable {
builder()
Expand Down Expand Up @@ -305,17 +278,6 @@ public void testkeyrefKeywordConref() throws Throwable {
builder().name(Paths.get("keyref", "keyword_conref")).transtype(PREPROCESS).input(Paths.get("test.ditamap")).test();
}

@Test
public void testmapref() throws Throwable {
builder()
.name(Paths.get("mapref", "basic"))
.transtype(PREPROCESS)
.input(Paths.get("test.ditamap"))
.put("generate-debug-attributes", "false")
.errorCount(0)
.test();
}

@Test
public void testuplevelslink() throws Throwable {
builder()
Expand Down
12 changes: 0 additions & 12 deletions src/test/java/org/dita/dost/IntegrationTestPreprocess2.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,18 +50,6 @@ public void testconrefmissingfile() throws Throwable {
.test();
}

@Test
public void testmapref() throws Throwable {
builder()
.name(Paths.get("mapref", "basic"))
.transtype(PREPROCESS)
.input(Paths.get("test.ditamap"))
.put("generate-debug-attributes", "false")
.errorCount(3)
.warnCount(1)
.test();
}

@Disabled
@Test
public void testcopyto_linktarget() throws Throwable {
Expand Down
11 changes: 0 additions & 11 deletions src/test/java/org/dita/dost/IntegrationTestXhtml.java
Original file line number Diff line number Diff line change
Expand Up @@ -330,17 +330,6 @@ public void testlang() throws Throwable {
.test();
}

@Test
public void testmapref() throws Throwable {
builder()
.name(Paths.get("mapref", "basic"))
.transtype(PREPROCESS)
.input(Paths.get("test.ditamap"))
.put("generate-debug-attributes", "false")
.errorCount(0)
.test();
}

@Test
public void testsubjectschema_case() throws Throwable {
builder()
Expand Down
10 changes: 7 additions & 3 deletions src/test/java/org/dita/dost/TestUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -282,9 +282,13 @@ public static void assertXMLEqual(Document exp, Document act) {
.build();
if (d.hasDifferences()) {
try {
TransformerFactory.newInstance().newTransformer().transform(new DOMSource(act), new StreamResult(System.out));
} catch (TransformerException e) {
throw new RuntimeException(e);
var transformerFactory = TransformerFactory.newInstance();
transformerFactory.newTransformer().transform(new DOMSource(exp), new StreamResult(System.out));
System.out.println();
transformerFactory.newTransformer().transform(new DOMSource(act), new StreamResult(System.out));
System.out.println();
} catch (TransformerException ex) {
//
}
throw new AssertionError(d.toString());
}
Expand Down
12 changes: 2 additions & 10 deletions src/test/java/org/dita/dost/module/AbstractModuleTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public abstract class AbstractModuleTest {
@TempDir
protected File tempBaseDir;

private final DocumentBuilder builder;
protected final DocumentBuilder builder;
protected String testCase;
protected Map<String, String> params = Collections.emptyMap();
protected boolean parallel;
Expand Down Expand Up @@ -226,15 +226,7 @@ private void compare(File actDir, File expDir, Store store) throws SAXException,
} else {
final Document expDoc = getDocument(exp);
final Document actDoc = store.getDocument(act.toURI());
// assertXMLEqual("Comparing " + exp + " to " + act + ":",
// expDoc, actDoc);
try {
assertXMLEqual(expDoc, actDoc);
} catch (AssertionError e) {
System.out.println(exp);
Files.copy(act.toPath(), System.out);
throw e;
}
assertXMLEqual(expDoc, actDoc);
}
}
if (new File(expDir, ".job.xml").exists()) {
Expand Down
79 changes: 79 additions & 0 deletions src/test/java/org/dita/dost/module/MaprefModuleTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
/*
* This file is part of the DITA Open Toolkit project.
*
* Copyright 2024 Jarno Elovirta
*
* See the accompanying LICENSE file for applicable license.
*/

package org.dita.dost.module;

import static org.dita.dost.util.Constants.ANT_INVOKER_EXT_PARAM_STYLE;
import static org.dita.dost.util.Constants.ANT_INVOKER_EXT_PARAM_TRANSTYPE;

import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import org.dita.dost.pipeline.AbstractPipelineInput;
import org.dita.dost.pipeline.PipelineHashIO;
import org.dita.dost.store.CacheStore;
import org.dita.dost.store.Store;
import org.dita.dost.util.Configuration;
import org.dita.dost.util.Job;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;
import org.xml.sax.SAXException;

class MaprefModuleTest extends AbstractModuleTest {

@Override
protected AbstractPipelineInput getAbstractPipelineInput() {
final AbstractPipelineInput input = new PipelineHashIO();
input.setAttribute(ANT_INVOKER_EXT_PARAM_TRANSTYPE, "html5");
input.setAttribute(
ANT_INVOKER_EXT_PARAM_STYLE,
new File("src/main/plugins/org.dita.base/xsl/preprocess/mapref.xsl").getAbsolutePath()
);
return input;
}

@Override
protected AbstractPipelineModule getModule() {
return new MaprefModule();
}

@ParameterizedTest
@ValueSource(strings = { "basic", "mapref_reltables", "mapref_to_conref", "mapref_topicrefID" })
public void process(String testCase) throws IOException {
this.testCase = testCase;
tempDir = new File(tempBaseDir, testCase);
job = new Job(tempDir, createStore());
mode = Configuration.Mode.LAX;
chunkModule.setProcessingMode(mode);
test();
}

private Store createStore() throws IOException {
final CacheStore store = new CacheStore(tempDir, xmlUtils);
var srcDir = Paths.get(resourceDir.getAbsolutePath(), "src", testCase);
Files
.walk(srcDir)
.filter(Files::isRegularFile)
.filter(file -> !file.getFileName().toString().equals(".job.xml"))
.forEach(src -> {
try {
var dst = tempDir.toPath().resolve(srcDir.relativize(src)).toUri();
var doc = builder.parse(src.toFile());
doc.insertBefore(
doc.createProcessingInstruction("workdir-uri", dst.resolve(".").toString()),
doc.getDocumentElement()
);
store.writeDocument(doc, dst);
} catch (IOException | SAXException e) {
throw new RuntimeException(e);
}
});
return store;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<?xml version="1.0" encoding="UTF-8"?>
<map xmlns:dita-ot="http://dita-ot.sourceforge.net/ns/201007/dita-ot"
xmlns:ditaarch="http://dita.oasis-open.org/architecture/2005/" audience="novice" cascade="nomerge"
class="- map/map " ditaarch:DITAArchVersion="1.3"
domains="(map mapgroup-d) (topic abbrev-d) (topic delay-d) a(props deliveryTarget) (map ditavalref-d) (map glossref-d) (topic hazard-d) (topic hi-d) (topic indexing-d) (topic markup-d) (topic pr-d) (topic relmgmt-d) (topic sw-d) (topic ui-d) (topic ut-d) (topic markup-d xml-d)"
specializations="@props/deliveryTarget">
<topicgroup class="+ map/topicref mapgroup-d/topicgroup ">
<submap class="+ map/topicref mapgroup-d/topicgroup ditaot-d/submap "
dita-ot:orig-class="+ map/topicref mapgroup-d/mapref " dita-ot:orig-format="ditamap"
dita-ot:orig-href="f1de8cb986a52d8ed0133cb2cc44d4823f150e93.ditamap" dita-ot:submap-DITAArchVersion="1.3"
dita-ot:submap-cascade="nomerge" dita-ot:submap-class="- map/map "
dita-ot:submap-domains="(map mapgroup-d) (topic abbrev-d) (topic delay-d) a(props deliveryTarget) (map ditavalref-d) (map glossref-d) (topic hazard-d) (topic hi-d) (topic indexing-d) (topic markup-d) (topic pr-d) (topic relmgmt-d) (topic sw-d) (topic ui-d) (topic ut-d) (topic markup-d xml-d)"
dita-ot:submap-otherprops="other" dita-ot:submap-specializations="@props/deliveryTarget" product="osx">
<submap-topicmeta class="+ map/topicmeta ditaot-d/submap-topicmeta ">
<submap-title class="+ topic/navtitle ditaot-d/submap-title " dita-ot:submap-class="- topic/title ">DITA Topic
Map
</submap-title>
</submap-topicmeta>
<topicref class="- map/topicref " href="93cd2060f88749614d44c00dade0e78c437afbc8.dita" otherprops="other"
props="props"/>
</submap>
<keydef class="+ map/topicref mapgroup-d/keydef ditaot-d/keydef " format="ditamap"
href="f1de8cb986a52d8ed0133cb2cc44d4823f150e93.ditamap" keys="A" processing-role="resource-only"/>
<submap class="+ map/topicref mapgroup-d/topicgroup ditaot-d/submap "
dita-ot:orig-class="+ map/topicref mapgroup-d/mapref " dita-ot:orig-format="ditamap"
dita-ot:orig-href="f1de8cb986a52d8ed0133cb2cc44d4823f150e93.ditamap" dita-ot:submap-DITAArchVersion="1.3"
dita-ot:submap-cascade="nomerge" dita-ot:submap-class="- map/map "
dita-ot:submap-domains="(map mapgroup-d) (topic abbrev-d) (topic delay-d) a(props deliveryTarget) (map ditavalref-d) (map glossref-d) (topic hazard-d) (topic hi-d) (topic indexing-d) (topic markup-d) (topic pr-d) (topic relmgmt-d) (topic sw-d) (topic ui-d) (topic ut-d) (topic markup-d xml-d)"
dita-ot:submap-otherprops="other" dita-ot:submap-specializations="@props/deliveryTarget">
<submap-topicmeta class="+ map/topicmeta ditaot-d/submap-topicmeta ">
<submap-title class="+ topic/navtitle ditaot-d/submap-title " dita-ot:submap-class="- topic/title ">DITA Topic
Map
</submap-title>
</submap-topicmeta>
<topicref class="- map/topicref " href="93cd2060f88749614d44c00dade0e78c437afbc8.dita" otherprops="other"
props="props"/>
</submap>
<mapref class="+ map/topicref mapgroup-d/mapref " format="ditamap" keyref="A"/>
<keydef class="+ map/topicref mapgroup-d/keydef ditaot-d/keydef " format="ditamap"
href="f1de8cb986a52d8ed0133cb2cc44d4823f150e93.ditamap" keys="B" processing-role="resource-only"/>
<submap class="+ map/topicref mapgroup-d/topicgroup ditaot-d/submap "
dita-ot:orig-class="+ map/topicref mapgroup-d/mapref " dita-ot:orig-format="ditamap"
dita-ot:orig-href="f1de8cb986a52d8ed0133cb2cc44d4823f150e93.ditamap" dita-ot:submap-DITAArchVersion="1.3"
dita-ot:submap-cascade="nomerge" dita-ot:submap-class="- map/map "
dita-ot:submap-domains="(map mapgroup-d) (topic abbrev-d) (topic delay-d) a(props deliveryTarget) (map ditavalref-d) (map glossref-d) (topic hazard-d) (topic hi-d) (topic indexing-d) (topic markup-d) (topic pr-d) (topic relmgmt-d) (topic sw-d) (topic ui-d) (topic ut-d) (topic markup-d xml-d)"
dita-ot:submap-otherprops="other" dita-ot:submap-specializations="@props/deliveryTarget">
<submap-topicmeta class="+ map/topicmeta ditaot-d/submap-topicmeta ">
<submap-title class="+ topic/navtitle ditaot-d/submap-title " dita-ot:submap-class="- topic/title ">DITA Topic
Map
</submap-title>
</submap-topicmeta>
<topicref class="- map/topicref " href="93cd2060f88749614d44c00dade0e78c437afbc8.dita" otherprops="other"
props="props"/>
</submap>
<submap class="+ map/topicref mapgroup-d/topicgroup ditaot-d/submap "
dita-ot:orig-class="+ map/topicref mapgroup-d/mapref " dita-ot:orig-format="ditamap"
dita-ot:orig-href="907876965ae3c4f4a6a10fd90639d07d5b82d618.ditamap" dita-ot:submap-DITAArchVersion="1.3"
dita-ot:submap-cascade="nomerge" dita-ot:submap-class="- map/map "
dita-ot:submap-domains="(map mapgroup-d) (topic abbrev-d) (topic delay-d) a(props deliveryTarget) (map ditavalref-d) (map glossref-d) (topic hazard-d) (topic hi-d) (topic indexing-d) (topic markup-d) (topic pr-d) (topic relmgmt-d) (topic sw-d) (topic ui-d) (topic ut-d) (topic markup-d xml-d)"
dita-ot:submap-specializations="@props/deliveryTarget" keyref="B">
<submap-topicmeta class="+ map/topicmeta ditaot-d/submap-topicmeta ">
<submap-title class="+ topic/navtitle ditaot-d/submap-title " dita-ot:submap-class="- topic/title ">DITA Topic
Map
</submap-title>
</submap-topicmeta>
<topicref class="- map/topicref " href="37661754edbfa28e7abc3f45365e412f3e0a14cd.dita"/>
</submap>
<mapref class="+ map/topicref mapgroup-d/mapref " format="ditamap" href="peer.ditamap" scope="peer"/>
</topicgroup>
</map>
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<map
xmlns:ditaarch="http://dita.oasis-open.org/architecture/2005/" ditaarch:DITAArchVersion="1.3"
domains="(map mapgroup-d) (topic abbrev-d) (topic delay-d) a(props deliveryTarget) (map ditavalref-d) (map glossref-d) (topic hazard-d) (topic hi-d) (topic indexing-d) (topic markup-d) (topic pr-d) (topic relmgmt-d) (topic sw-d) (topic ui-d) (topic ut-d) (topic markup-d xml-d)"
class="- map/map " cascade="nomerge" specializations="@props/deliveryTarget">
<title class="- topic/title ">DITA Topic Map</title>
<topicref href="37661754edbfa28e7abc3f45365e412f3e0a14cd.dita" class="- map/topicref "/>
</map>
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<map
xmlns:ditaarch="http://dita.oasis-open.org/architecture/2005/" otherprops="other" ditaarch:DITAArchVersion="1.3"
domains="(map mapgroup-d) (topic abbrev-d) (topic delay-d) a(props deliveryTarget) (map ditavalref-d) (map glossref-d) (topic hazard-d) (topic hi-d) (topic indexing-d) (topic markup-d) (topic pr-d) (topic relmgmt-d) (topic sw-d) (topic ui-d) (topic ut-d) (topic markup-d xml-d)"
class="- map/map " cascade="nomerge" specializations="@props/deliveryTarget">
<title class="- topic/title ">DITA Topic Map</title>
<topicref href="93cd2060f88749614d44c00dade0e78c437afbc8.dita" props="props" class="- map/topicref "/>
</map>
Loading

0 comments on commit 318429b

Please sign in to comment.