Schematron: add attribute value to XREF
Posted: Tue Jan 21, 2020 1:53 pm
Hi,
All my xref elements with the @format 'dita' require a @platform attribute (value mechanical or terminal).
If the @platform element is not added, I would like to add a quickfix to add the attibute value.
My search is currently working, but the quickfix is not working yet.
The attribute value is not added the XREF element.
Anyone who can help me to add the attribute value.
This is my schematron:
All my xref elements with the @format 'dita' require a @platform attribute (value mechanical or terminal).
If the @platform element is not added, I would like to add a quickfix to add the attibute value.
My search is currently working, but the quickfix is not working yet.
The attribute value is not added the XREF element.
Anyone who can help me to add the attribute value.
This is my schematron:
Code: Select all
<?xml version="1.0" encoding="UTF-8"?><schema xmlns="http://purl.oclc.org/dsdl/schematron" xmlns:sqf="http://www.schematron-quickfix.com/validator/process" queryBinding="xslt2">
<pattern abstract="true" id="requiredAttribute">
<title>Required Attributes</title>
<rule context="$context">
<assert test="$attribute= $terminal or $mechanical" sqf:fix="add_attribute_mechanical add_attribute_display">
The <name/> element should have a
<value-of select="$attribute/name()"/> attribute.
</assert>
<sqf:fix id="add_attribute_mechanical">
<sqf:description>
<sqf:title>Adds the value 'mechanical' to the @plaform attribute</sqf:title>
</sqf:description>
<sqf:add match="." node-type="attribute" target="platform">
<value-of select=".">mechanical</value-of>
</sqf:add>
</sqf:fix>
<sqf:fix id="add_attribute_display">
<sqf:description>
<sqf:title>Adds the value 'terminal' to the @platform attribute</sqf:title>
</sqf:description>
<sqf:add match="." node-type="attribute" target="platform">
<value-of select=".">terminal</value-of>
</sqf:add>
</sqf:fix>
</rule>
</pattern>
<pattern is-a="requiredAttribute">
<param name="context" value="xref[@format='dita']"/>
<param name="attribute" value="@platform"/>
<param name="terminal" value="terminal"/>
<param name="mechanical" value="mechanical"/>
</pattern>
</schema>