-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change html-chunker into an XProc step
Also add an XProcSpec test.
- Loading branch information
Showing
10 changed files
with
280 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<p:declare-step type="px:html-chunker" | ||
xmlns:p="http://www.w3.org/ns/xproc" | ||
xmlns:px="http://www.daisy.org/ns/pipeline/xproc" | ||
exclude-inline-prefixes="#all" | ||
version="1.0"> | ||
|
||
<p:input port="source"/> | ||
<p:output port="result" sequence="true"> | ||
<p:pipe step="xslt" port="secondary"/> | ||
</p:output> | ||
|
||
<p:xslt name="xslt"> | ||
<p:input port="stylesheet"> | ||
<p:document href="../xslt/html-chunker.xsl"/> | ||
</p:input> | ||
<p:input port="parameters"> | ||
<p:empty/> | ||
</p:input> | ||
</p:xslt> | ||
<p:sink/> | ||
|
||
</p:declare-step> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import org.daisy.pipeline.junit.AbstractXSpecAndXProcSpecTest; | ||
|
||
import org.junit.Test; | ||
|
||
public class XProcSpecTest extends AbstractXSpecAndXProcSpecTest { | ||
|
||
@Override @Test | ||
public void runXSpec() { | ||
// already run with xspec-maven-plugin | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<!--*- nxml -*--> | ||
<xproc-config xmlns="http://xmlcalabash.com/ns/configuration" | ||
xmlns:px="http://www.daisy.org/ns/pipeline/xproc" | ||
xmlns:letex="http://www.le-tex.de/namespace"> | ||
|
||
<implementation type="px:info" class-name="com.xmlcalabash.extensions.fileutils.Info"/> | ||
<implementation type="px:unzip" class-name="com.xmlcalabash.extensions.Unzip"/> | ||
<implementation type="px:zip" class-name="com.xmlcalabash.extensions.Zip"/> | ||
<implementation type="letex:unzip" class-name="org.daisy.common.xproc.calabash.steps.UnZipProvider.UnZip"/> | ||
|
||
</xproc-config> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
pax.exam.logging = none |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<configuration> | ||
|
||
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> | ||
<encoder> | ||
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern> | ||
</encoder> | ||
</appender> | ||
|
||
<appender name="TEST_LOG" class="ch.qos.logback.core.FileAppender"> | ||
<file>target/test.log</file> | ||
<encoder> | ||
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern> | ||
</encoder> | ||
</appender> | ||
|
||
<root level="WARN"> | ||
<appender-ref ref="TEST_LOG"/> | ||
</root> | ||
|
||
<logger name="org.daisy" level="DEBUG"/> | ||
<logger name="com.xmlcalabash" level="DEBUG"/> | ||
|
||
</configuration> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,165 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<x:description xmlns:x="http://www.daisy.org/ns/xprocspec" | ||
xmlns:p="http://www.w3.org/ns/xproc" | ||
xmlns:px="http://www.daisy.org/ns/pipeline/xproc" | ||
xmlns:epub="http://www.idpf.org/2007/ops" | ||
xmlns="http://www.w3.org/1999/xhtml" | ||
script="../../main/resources/xml/xproc/html-chunker.xpl"> | ||
|
||
<x:scenario label="section based chunking"> | ||
<x:call step="px:html-chunker"> | ||
<x:input port="source"> | ||
<x:document type="inline"> | ||
<html> | ||
<body> | ||
<section epub:type="frontmatter"> | ||
<section/> | ||
<section/> | ||
</section> | ||
<section epub:type="bodymatter"> | ||
<section/> | ||
<p/> | ||
<p/> | ||
<section/> | ||
</section> | ||
</body> | ||
</html> | ||
</x:document> | ||
</x:input> | ||
</x:call> | ||
<x:context label="the chunks"> | ||
<x:document type="port" port="result"/> | ||
</x:context> | ||
<x:expect label="frontmatter in one chunk, each bodymatter subsections in its own chunk" type="compare"> | ||
<x:document type="inline"> | ||
<html> | ||
<body epub:type="frontmatter"> | ||
<section/> | ||
<section/> | ||
</body> | ||
</html> | ||
</x:document> | ||
<x:document type="inline"> | ||
<html> | ||
<body epub:type="bodymatter"> | ||
<section/> | ||
</body> | ||
</html> | ||
</x:document> | ||
<x:document type="inline"> | ||
<html> | ||
<body epub:type="bodymatter"> | ||
<p/> | ||
<p/> | ||
</body> | ||
</html> | ||
</x:document> | ||
<x:document type="inline"> | ||
<html> | ||
<body epub:type="bodymatter"> | ||
<section/> | ||
</body> | ||
</html> | ||
</x:document> | ||
</x:expect> | ||
</x:scenario> | ||
|
||
<x:scenario label="title"> | ||
<x:call step="px:html-chunker"> | ||
<x:input port="source"> | ||
<x:document type="inline"> | ||
<html> | ||
<head> | ||
<title>foo</title> | ||
</head> | ||
<body> | ||
<section> | ||
<h1>A</h1> | ||
</section> | ||
<section> | ||
<h1>B</h1> | ||
</section> | ||
<section/> | ||
</body> | ||
</html> | ||
</x:document> | ||
</x:input> | ||
</x:call> | ||
<x:context label="the chunks"> | ||
<x:document type="port" port="result"/> | ||
</x:context> | ||
<x:expect label="each chunk gets its own title based on the body contents" type="compare"> | ||
<x:document type="inline"> | ||
<html> | ||
<head> | ||
<title>A</title> | ||
</head> | ||
<body> | ||
<h1>A</h1> | ||
</body> | ||
</html> | ||
</x:document> | ||
<x:document type="inline"> | ||
<html> | ||
<head> | ||
<title>B</title> | ||
</head> | ||
<body> | ||
<h1>B</h1> | ||
</body> | ||
</html> | ||
</x:document> | ||
<x:document type="inline"> | ||
<html> | ||
<head> | ||
<title>foo</title> | ||
</head> | ||
<body/> | ||
</html> | ||
</x:document> | ||
</x:expect> | ||
</x:scenario> | ||
|
||
<x:scenario label="link correction"> | ||
<x:call step="px:html-chunker"> | ||
<x:input port="source"> | ||
<x:document type="inline"> | ||
<html> | ||
<body> | ||
<section> | ||
<h1>a</h1> | ||
<a href="#x"/> | ||
</section> | ||
<section> | ||
<h1>b</h1> | ||
<p id="x"/> | ||
</section> | ||
</body> | ||
</html> | ||
</x:document> | ||
</x:input> | ||
</x:call> | ||
<x:context label="the chunks"> | ||
<x:document type="port" port="result"/> | ||
</x:context> | ||
<x:expect label="links between chunks are corrected" type="compare"> | ||
<x:document type="inline"> | ||
<html> | ||
<body> | ||
<h1>a</h1> | ||
<a href="html-chunker-2.xprocspec#x"/> | ||
</body> | ||
</html> | ||
</x:document> | ||
<x:document type="inline"> | ||
<html> | ||
<body> | ||
<h1>b</h1> | ||
<p id="x"/> | ||
</body> | ||
</html> | ||
</x:document> | ||
</x:expect> | ||
</x:scenario> | ||
|
||
</x:description> |