Venus Fugerit Doc sample showing how to validate source documents
This project is part of a series of mini tutorial on Venus Fugerit Doc, here you can find the other tutorials.
- JDK 8+ (*)
- Maven 3.8+
This is a sample project configured using fj-doc-maven-plugin init plugin.
flavour : vanilla
Creation command :
mvn org.fugerit.java:fj-doc-maven-plugin:8.16.5:init \
-DgroupId=org.fugerit.java.demo \
-DartifactId=venus-sample-validating-source \
-Dextensions=base,freemarker \
-Dflavour=vanillaWhen writing a Venus Fugerit Doc source document :
<row><para>This element is not allowed this</para>
<cell><para>Luthien</para></cell>
<cell><para>Tinuviel</para></cell>
<cell><para>Queen</para></cell>
</row>It is possible to validate the XML source document by adding validating and/or failOnValidate properties to freemarker-doc-process-config :
<freemarker-doc-process-config
xmlns="https://freemarkerdocprocess.fugerit.org"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://freemarkerdocprocess.fugerit.org https://www.fugerit.org/data/java/doc/xsd/freemarker-doc-process-1-0.xsd"
validating="true"
failOnValidate="true">This will print validation information (and eventually fail if failOnValidate is set to true) :
[main] WARN org.fugerit.java.doc.freemarker.process.DocInputProcess - DocValidationResult failed!, errors : 2
[main] WARN org.fugerit.java.doc.freemarker.process.DocInputProcess - Validation error 0, org.xml.sax.SAXParseException; lineNumber: 39; columnNumber: 28; cvc-complex-type.2.4.a: Invalid content was found starting with element '{"http://javacoredoc.fugerit.org":para}'. One of '{"http://javacoredoc.fugerit.org":cell}' is expected.
[main] WARN org.fugerit.java.doc.freemarker.process.DocInputProcess - Validation error 1, org.xml.sax.SAXParseException; lineNumber: 44; columnNumber: 28; cvc-complex-type.2.4.a: Invalid content was found starting with element '{"http://javacoredoc.fugerit.org":para}'. One of '{"http://javacoredoc.fugerit.org":cell}' is expected.
Here are the resources we modified for this example :
- the Venus Fugerit Doc configuration fm-doc-process-config.xml
- dynamic data generated by a freemarker template document.ftl
- the JUnit putting all together DocHelperTest.java
NOTE: the printed errors are related to the XML source after FreeMarker template processing.