-
Notifications
You must be signed in to change notification settings - Fork 36
Maven plugin
Maven plugin to convert Schematron (SCH) to XSLT at compile time using ph-schematron-xslt
as the converter.
The conversion of Schematron to XSLT may be quite time consuming. That’s why this Maven plugin that does the conversion at build time to avoid perfoming the conversion every time.
By default the plugin is run in the Maven lifecycle phase generate-resources. The basic configuration of the plugin in the pom.xml
looks like this (inside the <build>/<plugins>
element), replacing x.y.z
with the latest version number.
<plugin>
<groupId>com.helger.maven</groupId>
<artifactId>ph-schematron-maven-plugin</artifactId>
<version>x.y.z</version>
<executions>
<execution>
<goals>
<goal>convert</goal>
</goals>
</execution>
</executions>
</plugin>
The possible configuration parameters are:
-
schematronDirectory
- The directory where the Schematron files reside. Defaults to${basedir}/src/main/schematron
. -
schematronPattern
- A pattern for the Schematron files. Can contain Ant-style wildcards and double wildcards. All files that match the pattern will be converted. Files in theschematronDirectory
and its subdirectories will be considered. Default is**/*.sch
. -
xsltDirectory
- The directory where the XSLT files will be saved. Default is${basedir}/src/main/xslt
. -
xsltExtension
- The file extension of the created XSLT files. Default is.xslt
. -
overwriteWithoutQuestion
- Overwrite existing Schematron files without notice? If this is set tofalse
than existing XSLT files are not overwritten. Default istrue
. -
phaseName
- Define the phase to be used for XSLT creation. By default thedefaultPhase
attribute of the Schematron file is used. -
languageCode
- Define the language code for the XSLT creation. Default isnull
which means English. Supported language codes are: cs, de, en, fr, nl.-
parameters
(since v5.0.2) - A map to provide custom parameter for the Schematron XSLTs (as inallow-foreign
). Example:
-
<configuration>
...
<parameters>
<allow-foreign>true</allow-foreign>
<anything>else</anything>
</parameters>
...
</configuration>
-
forceCacheResult
(since v.5.2.1) - Force the caching of results from SCH to XSLT. -
xsltHeader
(since v6.2.2) - An optional header text that is added to all created XSLT files. The text will be added as an XML comment and can be multiline. -
showProgress
(since v6.2.8) - Enable or disable the progress indicator, if the conversion takes longer then 5 seconds. Enabled by default.
Maven plugin to validate XML files against convert Schematron (SCH) at compile time using ph-schematron as the validator.
This plugin was introduced in version 4.2.0.
By default the plugin is run in the Maven lifecycle phase process-resources. The basic configuration of the plugin in the pom.xml
looks like this (inside the <build>/<plugins>
element), replacing x.y.z
with the latest version number:
<plugin>
<groupId>com.helger.maven</groupId>
<artifactId>ph-schematron-maven-plugin</artifactId>
<version>x.y.z</version>
<executions>
<execution>
<goals>
<goal>validate</goal>
</goals>
</execution>
</executions>
</plugin>
The possible configuration parameters are:
-
schematronFile
- The Schematron file to be applied. This parameter is mandatory. -
schematronProcessingEngine
- The Schematron processing engine to be used. Can be one ofpure
(pure implementation),schematron
(Schematron to XSLT engine) andxslt
(pre-compiled XSLT files available). Default isschematron
since v6 (was previouslypure
). -
xmlDirectory
- The directory where the XML files to be validated are contained. It is expected that the XML files in this directory match the Schematron rules. Either this parameter orxmlErrorDirectory
parameter are mandatory. -
xmlIncludes
- A pattern for the XML files to be included. Can contain Ant-style wildcards and double wildcards. All files that match the pattern will be validated. Files in thexmlDirectory
and its subdirectories will be considered. Default is**/*.xml
. Since v6.2.1 this is of typeString[]
, previously it wasString
. -
xmlExcludes
- A pattern for the XML files to be excluded. Can contain Ant-style wildcards and double wildcards. All files that match the pattern will NOT be validated. Files in thexmlDirectory
and its subdirectories will be considered. Since v6.2.1 this is of typeString[]
, previously it wasString
. -
svrlDirectory
- The directory where the SVRL (Schematron Validation Report Language) files will be saved. If this property is not specified, no SVRL files will be written. By default the name of the SVRL file corresponds to the XML file that is validated (defined by the parametersxmlDirectory
,xmlIncludes
andxmlExcludes
) with the suffix.svrl
. -
xmlErrorDirectory
(since v4.3.0) - The directory where the XML files to be validated are contained. It is expected that the XML files in this directory do not match the Schematron rules. Either this parameter orxmlDirectory
parameter are mandatory. -
xmlErrorIncludes
(since v4.3.0) - A pattern for the erroneous XML files to be included. Can contain Ant-style wildcards and double wildcards. All files that match the pattern will be validated. Files in thexmlDirectory
and its subdirectories will be considered. Default is**/*.xml
. Since v6.2.1 this is of typeString[]
, previously it wasString
. -
xmlErrorExcludes
(since v4.3.0) - A pattern for the erroneous XML files to be excluded. Can contain Ant-style wildcards and double wildcards. All files that match the pattern will NOT be validated. Files in thexmlDirectory
and its subdirectories will be considered. Since v6.2.1 this is of typeString[]
, previously it wasString
. -
svrlErrorDirectory
(since v4.3.0) - The directory where the erroneous SVRL files will be saved. If this property is not specified, no SVRL files will be written. By default the name of the SVRL file corresponds to the XML file that is validated (defined by the parametersxmlErrorDirectory
,xmlErrorIncludes
andxmlErrorExcludes
) with the suffix.svrl
. -
phaseName
- Define the phase to be used for XSLT creation. By default thedefaultPhase
attribute of the Schematron file is used. -
languageCode
- Define the language code for the XSLT creation. Default isnull
which means English. Supported language codes are: cs, de, en, fr, nl. -
parameters
(since v5.0.2) - Custom attributes to be used for the SCH to XSLT conversion. This parameter takes only effect when using schematronProcessingEngine "schematron" or "xslt". By default no parameter is present. -
failFast
(since v5.0.5) - If multiple XML files are validated this parameter defines whether the execution should fail at the first error (valuetrue
) or at the end only (valuefalse
). The default value istrue
. -
forceCacheResult
(since v5.2.1) - Force the caching of results of the conversion from SCH to XSLT (the default isfalse
) -
lenient
(since v5.4.1) - If enabled, old deprecated Schematron namespace URIs can be read. This only has an effect when used with the "pure" engine (the default isfalse
) -
ignoreWarnings
(since v7.1.2) - If enabled, warnings will not be emitted and will not make the validation fail (the default isfalse
)
Maven plugin to preprocess a Schematron file and write the resulting file to disk.
This plugin was introduced in version 5.0.9.
By default the plugin is run in the Maven lifecycle phase generate-resources. The basic configuration of the plugin in the pom.xml
looks like this (inside the <build>/<plugins>
element), replacing x.y.z
with the latest version number:
<plugin>
<groupId>com.helger.maven</groupId>
<artifactId>ph-schematron-maven-plugin</artifactId>
<version>x.y.z</version>
<executions>
<execution>
<goals>
<goal>preprocess</goal>
</goals>
</execution>
</executions>
</plugin>
The possible configuration parameters are:
-
sourceFile
- The source Schematron file to be preprocessed. This parameter is mandatory. -
targetFile
- The target (preprocessed) Schematron file to be written. This parameter is mandatory. -
overwriteWithoutNotice
- Overwrite existing Schematron files without notice? If this is set tofalse
than existing Schematron files are not overwritten. The default value istrue
. -
keepTitles
- If this is set tofalse
than<title>
elements will be removed. The default value isfalse
. -
keepDiagnostics
- If this is set tofalse
than<diagnostic>
elements will be removed. The default value isfalse
. -
keepReports
- Should<report>
elements be kept or should they be converted to<assert>
elements? The default value isfalse
. -
keepEmptyPatterns
- Should<pattern>
elements without a single rule be kept or deleted? The default value isfalse
. -
schHeader
(since v6.2.2) - An optional header text that is added to all created SCH files. The text will be added as an XML comment and can be multiline.
On Twitter: Follow @philiphelger
Donation link: https://paypal.me/PhilipHelger
It is appreciated if you star the GitHub project if you like it.