Skip to content

Commit

Permalink
Introduce schema 7.1
Browse files Browse the repository at this point in the history
This introduces a backwards-compatible 7.1 schema that allows for the
specification of new metadata properties. This allows for, for example,
defining EPUB cover images. The existing 7.0 schema was updated to
allow for extension, but no validation-time behaviour has changed. The
stylesheets have been updated to handle elements from both schemas.

Affects: #13
  • Loading branch information
io7m committed Jun 26, 2021
1 parent 0c88747 commit 7856de0
Show file tree
Hide file tree
Showing 14 changed files with 1,093 additions and 181 deletions.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Expand Up @@ -31,14 +31,16 @@
text-align: left;
padding-right: 1em;
padding-bottom: 1em;
font-size: var(--stFontSize);
}
.parametersTable td
{
padding-right: 1em;
padding-bottom: 0.5em;
vertical-align: top;
font-size: var(--stFontSize);
}
.parametersTable td:nth-child(1)
{
width: 8em;
width: 12em;
}
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8" ?>

<Document xmlns="urn:com.io7m.structural:7:0"
<Document xmlns="urn:com.io7m.structural:7:1"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:xi="http://www.w3.org/2001/XInclude"
tableOfContentsDepth="1">
Expand All @@ -10,6 +10,7 @@
<dc:identifier>d792ce57-6851-415a-b6c9-18550e512136</dc:identifier>
<dc:description>User documentation for the ${project.groupId} package.</dc:description>
<dc:language>en</dc:language>
<MetaProperty name="cover">cover.jpg</MetaProperty>
</Metadata>

<xi:include href="cmdline.xml"/>
Expand Down
Expand Up @@ -25,6 +25,7 @@
import java.io.UncheckedIOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.stream.Collectors;

import static java.nio.charset.StandardCharsets.UTF_8;

Expand Down Expand Up @@ -96,6 +97,24 @@ public void testValidateOK()
Assertions.assertEquals(0, main.exitCode());
}

@Test
public void testValidateOK_71()
throws Exception
{
final var main = new Main(new String[]{
"validate",
"--sourceFile",
XSTestDirectories.resourceOf(
XSCommandLineTest.class,
this.sourceDirectory,
"example0_71.xml")
.toString(),
"--verbose",
"trace"
});
main.run();
Assertions.assertEquals(0, main.exitCode());
}

@Test
public void testTransformXHTMLMissingOutput()
Expand Down Expand Up @@ -148,6 +167,27 @@ public void testTransformXHTMLOK()
Assertions.assertEquals(0, main.exitCode());
}

@Test
public void testTransformXHTMLOK_71()
throws Exception
{
final var main = new Main(new String[]{
"xhtml",
"--sourceFile",
XSTestDirectories.resourceOf(
XSCommandLineTest.class,
this.sourceDirectory,
"example0_71.xml")
.toString(),
"--outputDirectory",
this.outputDirectory.toString(),
"--verbose",
"trace"
});
main.run();
Assertions.assertEquals(0, main.exitCode());
}

@Test
public void testTransformXHTMLSingleOK()
throws Exception
Expand Down Expand Up @@ -188,6 +228,46 @@ public void testTransformXHTMLSingleOK()
);
}

@Test
public void testTransformXHTMLSingleOK_71()
throws Exception
{
final var main = new Main(new String[]{
"xhtml",
"--sourceFile",
XSTestDirectories.resourceOf(
XSCommandLineTest.class,
this.sourceDirectory,
"example0_71.xml")
.toString(),
"--outputDirectory",
this.outputDirectory.toString(),
"--traceFile",
this.directory.resolve("trace.xml").toString(),
"--messagesFile",
this.directory.resolve("messages.log").toString(),
"--verbose",
"trace",
"--stylesheet",
"SINGLE_FILE"
});
main.run();
Assertions.assertEquals(0, main.exitCode());

Assertions.assertTrue(
Files.isRegularFile(this.directory.resolve("trace.xml")),
"Trace file exists"
);
Assertions.assertTrue(
Files.isRegularFile(this.directory.resolve("messages.log")),
"Messages file exists"
);
Assertions.assertTrue(
Files.isRegularFile(this.outputDirectory.resolve("index.xhtml")),
"Index file exists"
);
}

@Test
public void testTransformXHTMLSingleBrandingOK()
throws Exception
Expand Down Expand Up @@ -230,6 +310,48 @@ public void testTransformXHTMLSingleBrandingOK()
);
}

@Test
public void testTransformXHTMLSingleBrandingOK_71()
throws Exception
{
final var main = new Main(new String[]{
"xhtml",
"--sourceFile",
XSTestDirectories.resourceOf(
XSCommandLineTest.class,
this.sourceDirectory,
"example0_71.xml")
.toString(),
"--outputDirectory",
this.outputDirectory.toString(),
"--traceFile",
this.directory.resolve("trace.xml").toString(),
"--messagesFile",
this.directory.resolve("messages.log").toString(),
"--verbose",
"trace",
"--brandingFile",
this.branding.toString(),
"--stylesheet",
"SINGLE_FILE"
});
main.run();
Assertions.assertEquals(0, main.exitCode());

Assertions.assertTrue(
Files.isRegularFile(this.directory.resolve("trace.xml")),
"Trace file exists"
);
Assertions.assertTrue(
Files.isRegularFile(this.directory.resolve("messages.log")),
"Messages file exists"
);
Assertions.assertTrue(
Files.isRegularFile(this.outputDirectory.resolve("index.xhtml")),
"Index file exists"
);
}

@Test
public void testTransformXHTMLMultiOK()
throws Exception
Expand Down Expand Up @@ -266,6 +388,42 @@ public void testTransformXHTMLMultiOK()
);
}

@Test
public void testTransformXHTMLMultiOK_71()
throws Exception
{
final var main = new Main(new String[]{
"xhtml",
"--sourceFile",
XSTestDirectories.resourceOf(
XSCommandLineTest.class,
this.sourceDirectory,
"example0_71.xml")
.toString(),
"--outputDirectory",
this.outputDirectory.toString(),
"--traceFile",
this.directory.resolve("trace.xml").toString(),
"--messagesFile",
this.directory.resolve("messages.log").toString(),
"--verbose",
"trace",
"--stylesheet",
"MULTIPLE_FILE"
});
main.run();
Assertions.assertEquals(0, main.exitCode());

Assertions.assertTrue(
Files.isRegularFile(this.directory.resolve("trace.xml")),
"Trace file exists"
);
Assertions.assertTrue(
Files.isRegularFile(this.directory.resolve("messages.log")),
"Messages file exists"
);
}

@Test
public void testTransformXHTMLMultiBrandingOK()
throws Exception
Expand Down Expand Up @@ -304,6 +462,44 @@ public void testTransformXHTMLMultiBrandingOK()
);
}

@Test
public void testTransformXHTMLMultiBrandingOK_71()
throws Exception
{
final var main = new Main(new String[]{
"xhtml",
"--sourceFile",
XSTestDirectories.resourceOf(
XSCommandLineTest.class,
this.sourceDirectory,
"example0_71.xml")
.toString(),
"--outputDirectory",
this.outputDirectory.toString(),
"--traceFile",
this.directory.resolve("trace.xml").toString(),
"--messagesFile",
this.directory.resolve("messages.log").toString(),
"--verbose",
"trace",
"--brandingFile",
this.branding.toString(),
"--stylesheet",
"MULTIPLE_FILE"
});
main.run();
Assertions.assertEquals(0, main.exitCode());

Assertions.assertTrue(
Files.isRegularFile(this.directory.resolve("trace.xml")),
"Trace file exists"
);
Assertions.assertTrue(
Files.isRegularFile(this.directory.resolve("messages.log")),
"Messages file exists"
);
}

@Test
public void testSchema()
throws Exception
Expand All @@ -315,7 +511,18 @@ public void testSchema()
});
main.run();
Assertions.assertEquals(0, main.exitCode());
Assertions.assertEquals(3L, Files.list(this.outputDirectory).count());

final var files =
Files.list(this.outputDirectory)
.map(Path::getFileName)
.map(Path::toString)
.collect(Collectors.toList());

Assertions.assertEquals(4L, (long) files.size());
Assertions.assertTrue(files.contains("xml.xsd"));
Assertions.assertTrue(files.contains("dc.xsd"));
Assertions.assertTrue(files.contains("xstructural-7.xsd"));
Assertions.assertTrue(files.contains("xstructural-7_1.xsd"));
}

@Test
Expand All @@ -329,7 +536,7 @@ public void testSchemaNoReplace()
});
main.run();
Assertions.assertEquals(0, main.exitCode());
Assertions.assertEquals(3L, Files.list(this.outputDirectory).count());
Assertions.assertEquals(4L, Files.list(this.outputDirectory).count());

Files.list(this.outputDirectory)
.forEach(path -> {
Expand All @@ -347,7 +554,7 @@ public void testSchemaNoReplace()
});
mainAgain.run();
Assertions.assertEquals(0, mainAgain.exitCode());
Assertions.assertEquals(3L, Files.list(this.outputDirectory).count());
Assertions.assertEquals(4L, Files.list(this.outputDirectory).count());

Files.list(this.outputDirectory)
.forEach(path -> {
Expand All @@ -371,7 +578,7 @@ public void testSchemaReplace()
});
main.run();
Assertions.assertEquals(0, main.exitCode());
Assertions.assertEquals(3L, Files.list(this.outputDirectory).count());
Assertions.assertEquals(4L, Files.list(this.outputDirectory).count());

Files.list(this.outputDirectory)
.forEach(path -> {
Expand All @@ -391,7 +598,7 @@ public void testSchemaReplace()
});
mainAgain.run();
Assertions.assertEquals(0, mainAgain.exitCode());
Assertions.assertEquals(3L, Files.list(this.outputDirectory).count());
Assertions.assertEquals(4L, Files.list(this.outputDirectory).count());

Files.list(this.outputDirectory)
.forEach(path -> {
Expand Down Expand Up @@ -565,4 +772,58 @@ public void testTransformXHTMLEPUBOKExample2()
"EPUB file exists"
);
}

@Test
public void testTransformXHTMLEPUBOKExample0_71()
throws Exception
{
XSTestDirectories.resourceOf(
XSCommandLineTest.class,
this.sourceDirectory,
"poppy.jpg"
);
XSTestDirectories.resourceOf(
XSCommandLineTest.class,
this.sourceDirectory,
"missing.jpg"
);
XSTestDirectories.resourceOf(
XSCommandLineTest.class,
this.sourceDirectory,
"woods.jpg"
);

final var main = new Main(new String[]{
"epub",
"--sourceFile",
XSTestDirectories.resourceOf(
XSCommandLineTest.class,
this.sourceDirectory,
"example0_71.xml")
.toString(),
"--outputDirectory",
this.outputDirectory.toString(),
"--traceFile",
this.directory.resolve("trace.xml").toString(),
"--messagesFile",
this.directory.resolve("messages.log").toString(),
"--verbose",
"trace"
});
main.run();
Assertions.assertEquals(0, main.exitCode());

Assertions.assertTrue(
Files.isRegularFile(this.directory.resolve("trace.xml")),
"Trace file exists"
);
Assertions.assertTrue(
Files.isRegularFile(this.directory.resolve("messages.log")),
"Messages file exists"
);
Assertions.assertTrue(
Files.isRegularFile(this.outputDirectory.resolve("output.epub")),
"EPUB file exists"
);
}
}

0 comments on commit 7856de0

Please sign in to comment.