Skip to content

Commit f897dbc

Browse files
committed
[fj-mod-doc-fop] error if a element <phrase> is inside a <cell> (proof of concept) #426
1 parent a51ac9c commit f897dbc

File tree

5 files changed

+145
-2
lines changed

5 files changed

+145
-2
lines changed

fj-doc-sample/pom.xml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,13 @@
103103
<dependency>
104104
<groupId>org.fugerit.java</groupId>
105105
<artifactId>fj-doc-lib-simpletable</artifactId>
106-
</dependency>
107-
106+
</dependency>
107+
108+
<dependency>
109+
<groupId>org.fugerit.java</groupId>
110+
<artifactId>fj-doc-lib-direct</artifactId>
111+
</dependency>
112+
108113
<dependency>
109114
<groupId>org.fugerit.java</groupId>
110115
<artifactId>fj-doc-mod-openpdf-ext</artifactId>
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
docTitle: 'Issue 426 POC'
3+
listSample:
4+
- field1: 1
5+
field2: 'test a'
6+
- field1: 2
7+
field2: 'test b'
8+
- field1: 3
9+
field2: 'test c'
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
---
2+
configId: 'venus-direct-config-sample'
3+
templatePath: '${projectBasedir}/src/main/resources/venus-config-direct/venus-template/'
4+
templateMode: 'folder'
5+
createParentDirectory: true
6+
handlerList:
7+
- type: org.fugerit.java.doc.freemarker.html.FreeMarkerHtmlTypeHandlerUTF8
8+
- type: org.fugerit.java.doc.base.typehandler.markdown.SimpleMarkdownExtTypeHandlerNoCommentsUTF8
9+
- type: org.fugerit.java.doc.freemarker.asciidoc.FreeMarkerAsciidocTypeHandlerUTF8
10+
- type: org.fugerit.java.doc.mod.poi.XlsxPoiTypeHandler
11+
- type: org.fugerit.java.doc.mod.fop.FreeMarkerFopTypeHandlerUTF8
12+
- type: org.fugerit.java.doc.mod.fop.PdfFopTypeHandler
13+
chainList:
14+
- chainId: 'issue-426'
15+
dataModelYaml: '${projectBasedir}/src/main/resources/venus-config-direct/data-model/issue-426.yaml'
16+
outputList:
17+
- outputId: 'issue-426.md'
18+
chainId: 'issue-426'
19+
handlerId: 'md'
20+
file: '${projectBasedir}/target/direct-sample/issue-426.md'
21+
- outputId: 'issue-426.adoc'
22+
chainId: 'issue-426'
23+
handlerId: 'adoc'
24+
file: '${projectBasedir}/target/direct-sample/issue-426.adoc'
25+
- outputId: 'issue-426.xlsx'
26+
chainId: 'issue-426'
27+
handlerId: 'xlsx'
28+
file: '${projectBasedir}/target/direct-sample/issue-426.xlsx'
29+
- outputId: 'issue-426.fo'
30+
chainId: 'issue-426'
31+
handlerId: 'fo'
32+
file: '${projectBasedir}/target/direct-sample/issue-426.fo'
33+
- outputId: 'issue-426.pdf'
34+
chainId: 'issue-426'
35+
handlerId: 'pdf'
36+
file: '${projectBasedir}/target/direct-sample/issue-426.pdf'
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
<#ftl output_format="XML"><#-- Set the output format for XML, not mandatory but reccomended, otherwise escaping should be handled in a cusomt way, for example through CDATA sections -->
2+
<?xml version="1.0" encoding="utf-8"?>
3+
<doc
4+
xmlns="http://javacoredoc.fugerit.org"
5+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
6+
xsi:schemaLocation="http://javacoredoc.fugerit.org https://www.fugerit.org/data/java/doc/xsd/doc-2-1.xsd" >
7+
8+
<#--
9+
This is a Venus Fugerit Doc (https://github.com/fugerit-org/fj-doc) FreeMarker Template XML (ftl[x]).
10+
For consideration of Venus Fugerit Doc and Apache FreeMarker integration see :
11+
https://venusdocs.fugerit.org/guide/#doc-freemarker-entry-point
12+
The result will be a :
13+
-->
14+
<!--
15+
This is a Venus Fugerit Doc (https://github.com/fugerit-org/fj-doc) XML Source Document.
16+
For documentation on how to write a valid Venus Doc XML Meta Model refer to :
17+
https://venusdocs.fugerit.org/guide/#doc-format-entry-point
18+
-->
19+
20+
<metadata>
21+
<!-- Margin for document : left;right;top;bottom -->
22+
<info name="margins">10;10;10;30</info>
23+
<!-- documenta meta information -->
24+
<info name="doc-title">${dataModel.docTitle}</info>
25+
<info name="doc-author">Matteo Franci</info>
26+
<info name="doc-language">it</info>
27+
<!-- only apply to xls/xlsx format -->
28+
<info name="excel-table-id">issue-426-table=issue-426-table</info>
29+
<!-- only apply to csv format -->
30+
<info name="csv-table-id">issue-426-table</info>
31+
<!-- font must be loaded -->
32+
<info name="default-font-name">TitilliumWeb</info>
33+
<!-- default table-border-collapse, can be 'separate' or 'collapse' -->
34+
<info name="table-border-collapse">collapse</info>
35+
<footer-ext>
36+
<para align="right">${r"${currentPage}"} / ${r"${pageCount}"}</para>
37+
</footer-ext>
38+
<bookmark-tree>
39+
<bookmark ref="top">${dataModel.docTitle}</bookmark>
40+
</bookmark-tree>
41+
</metadata>
42+
43+
<body>
44+
45+
<h head-level="1" id="top" size="16">${dataModel.docTitle}</h>
46+
47+
<table colwidths="50;50" columns="2" width="100" id="issue-426-table">
48+
<row header="true">
49+
<cell align="center"><para style="bold">Field 1</para></cell>
50+
<cell align="center"><para style="bold">Field 2</para></cell>
51+
</row>
52+
<#list dataModel.listSample as current>
53+
<row>
54+
<cell><phrase>${current.field1}</phrase></cell>
55+
<cell><phrase>${current.field2}</phrase></cell>
56+
</row>
57+
</#list>
58+
</table>
59+
60+
</body>
61+
62+
</doc>
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package test.org.fugerit.java.doc.sample;
2+
3+
import org.fugerit.java.core.cfg.ConfigRuntimeException;
4+
import org.fugerit.java.core.lang.helpers.ClassHelper;
5+
import org.fugerit.java.doc.lib.direct.VenusDirectFacade;
6+
import org.fugerit.java.doc.lib.direct.config.VenusDirectConfig;
7+
import org.junit.jupiter.api.Assertions;
8+
import org.junit.jupiter.api.Test;
9+
10+
import java.io.File;
11+
import java.io.IOException;
12+
import java.io.InputStreamReader;
13+
import java.io.Reader;
14+
import java.util.HashMap;
15+
import java.util.Map;
16+
17+
class TestSampleDirect {
18+
19+
@Test
20+
void testDirect() throws IOException {
21+
try (Reader reader = new InputStreamReader(ClassHelper.loadFromDefaultClassLoader( "venus-config-direct/venus-direct-config.yaml" ) )) {
22+
Map<String, String> envMap = new HashMap<>();
23+
envMap.put( "projectBasedir", "." );
24+
VenusDirectConfig config = VenusDirectFacade.readConfig( reader, envMap );
25+
Assertions.assertThrows( ConfigRuntimeException.class, ()-> VenusDirectFacade.handleAllOutput( config ) );
26+
}
27+
File testOutputMd = new File( "./target/direct-sample/issue-426.md" );
28+
Assertions.assertTrue( testOutputMd.exists() );
29+
}
30+
31+
}

0 commit comments

Comments
 (0)