- How to define your own XML schema?
- How to configure the XML processor?
- How to add custom actions and tabs to Smart Document Pane?
- How to configure callback handler?
- How to configure Schematron content validation rules?
- How to configure track-changes content validation rules?
- How to configure content validation rules?
How to configure content validation rules?
The Content Validation Rules Sample provides a set of XPath and regular expression based validation and auto resolve rules.
The system integrator can configure an XPath that selects node in the content which are then matched using the supplied Regex expression. The nodes that match the regex are flagged as failing the rule. The user can configure many such rules that the content based. Please refer to the following configuration section for examples.
The user can also configure the error message shown for the nodes and the highlight color to be used for the erroneous nodes.
As a sample demonstration, the sample also supports a regular expression based validation and automatic resolve rules. This sample maps the regex for symbols $ and € and converts them to USD and EUR respectively, If symbols are placed before numerical value. (E.g. $23 to USD23).
Configuration
To configure the Content Validation Rules Sample, follow the steps mentioned below:
- Copy the following files to the Quark XML Author installation folder, e.g. “C:\Program Files (x86)\Quark\Quark XML Author”
Quark.CMSAdapters.Samples.XA.ContentValidation.dll
-
Quark.CMSAdapters.Samples.XA.ContentValidation.pdb
- Add the highlighted EIs below to the
[Language Folder]/AppConfig/AppConfig-ext/MethodInfo_ext.xml
file
<Method id="TrailingLeadingSpacesValidationRuleInfo" assembly="Quark.CMSAdapters.Samples.XA.ContentValidation" class="Quark.CMSAdapters.Samples.XA.ContentValidation.ExtensibilityMethods" method="RegexValidationRuleInfo" >
<Argument type="Tokens" >
<Token> name=Trailing or Leading Spaces Validation Rule </Token>
<Token> description=Checks whether paragraphs have leading or trailing spaces. </Token>
</Argument>
</Method>
<Method id="TrailingLeadingSpacesValidationRule" assembly="Quark.CMSAdapters.Samples.XA.ContentValidation" class="Quark.CMSAdapters.Samples.XA.ContentValidation.ExtensibilityMethods" method="RegexValidationRule" >
<Argument type="XomRoot" />
<Argument type="Tokens" >
<Token>xpath=//p</Token>
<Token>regex=^\s+|\s+$</Token>
<Token>error=The node contains tracked changes.</Token>
<Token>highlightcolor=Yellow</Token>
</Argument>
</Method>
The sample also provides for auto correction of invalid rules. This can be configured as below. The following example fixes the leading and trailing spaces in a paragraph by deleting them.
<Method id="TrailingLeadingSpacesAutoResolveRule" assembly="Quark.CMSAdapters.Samples.XA.ContentValidation" class="Quark.CMSAdapters.Samples.XA.ContentValidation.ExtensibilityMethods" method="RegexAutoResolveRule" >
<Argument type="XomRoot" />
<Argument type="Tokens" >
<Token>xpath=//p</Token>
<Token>regex=^\s+|\s+$</Token>
<Token>replacement=</Token>
</Argument>
</Method>
<Method id="TrailingLeadingSpacesAutoResolveRuleInfo" assembly="Quark.CMSAdapters.Samples.XA.ContentValidation" class="Quark.CMSAdapters.Samples.XA.ContentValidation.ExtensibilityMethods" method="RegexValidationRuleInfo" >
<Argument type="Tokens" >
<Token> name=Trailing or Leading Spaces automatic resolve rule.</Token>
<Token> description=Checks and automatically removes leading and trailing spaces from paragraphs.</Token>
</Argument >
Other examples may include currency conversion. For example look at the below configuration examples that replace the $ and € to their respective full forms.
<Method id="USDCurrencyAutoResolveRule" assembly="Quark.CMSAdapters.Samples.XA.ContentValidation" class="Quark.CMSAdapters.Samples.XA.ContentValidation.ExtensibilityMethods" method="RegexAutoResolveRule">
<Argument type="XomRoot"/>
<Argument type="Tokens">
<Token> xpath=//p </Token>
<Token> regex=(\$)(\s?((\d{1,3},?)+[.?\d{2}]?)) </Token>
<Token> replacement=USD$2 </Token>
</Argument>
</Method>
<Method id="USDCurrencyAutoResolveRuleInfo" assembly="Quark.CMSAdapters.Samples.XA.ContentValidation" class="Quark.CMSAdapters.Samples.XA.ContentValidation.ExtensibilityMethods" method="RegexValidationRuleInfo" >
<Argument type="Tokens">
<Token> name=US Dollar currency auto converter rule </Token>
<Token> description=Auto corrects $ symbols to USD in paragraphs. </Token>
</Argument >
</Method >
<Method id="EuroCurrencyAutoResolveRule" assembly="Quark.CMSAdapters.Samples.XA.ContentValidation" class="Quark.CMSAdapters.Samples.XA.ContentValidation.ExtensibilityMethods" method="RegexAutoResolveRule" >
<Argument type="XomRoot"/ >
<Argument type="Tokens" >
<Token> xpath=//p < /Token >
<Token> regex=(\€)(\s?((\d{1,3},?)+[.?\d{2}]?))</Token>
<Token> replacement=EUR$2 </Token >
</Argument >
</Method >
<Method id="EuroCurrencyAutoResolveRuleInfo" assembly="Quark.CMSAdapters.Samples.XA.ContentValidation" class="Quark.CMSAdapters.Samples.XA.ContentValidation.ExtensibilityMethods" method="RegexValidationRuleInfo" >
<Argument type="Tokens" >
<Token> name=Euro currency auto converter rule </Token >
<Token> description=Auto corrects € symbols to EUR in paragraphs.</Token>
</Argument>
</Method>
Modify the Quark.CMSAdapters.config
file to add the EI methods to the ContentValidationRules/RuleSet/Rule
configuration section. The sample snippet below only demonstrates configuration for the SAVE trigger, the same can be done for OUTPUT, EXPORT and CUSTOM triggers as well.
<ContentValidationRules>
<RuleSet componentRoot="topic" productLine="busdoc">
<Rule id="SaveRules" trigger="SAVE" condition="" policy="PROHIBIT" externalMethodIds="EuroCurrencyAutoResolveRule, USDCurrencyAutoResolveRule, TrailingLeadingSpacesAutoResolveRule"/>
</RuleSet>
</ContentValidationRules>
If rules are configured for CUTSOM trigger then it is up to the system integrator how they want to invoke these rules.
If the sample is configured with Quark Publishing Platform, you could additionally configure the condition for the rule to be triggered on a specific workflow and status. In that case the appropriate check-in or output evaluation policy also needs to be set on the workflow/status