Schematron: add attribute value to XREF
Post here questions and problems related to editing and publishing DITA content.
-
- Posts: 42
- Joined: Wed Jun 20, 2018 11:30 am
Schematron: add attribute value to XREF
Post by pieterjan_vdw »
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>
-
- Posts: 9436
- Joined: Fri Jul 09, 2004 5:18 pm
Re: Schematron: add attribute value to XREF
Hi Pieterjan,
I would suggest these changes:
I also assumed that you want to also match xref's which do not have the @format attribute (because by default if the format attribute is missing, then it is interpreted as a reference to a DITA topic). Also I restricted the assert to not match <xref> elements which already have the @platform attribute set on them.
Regards,
Radu
I would suggest these changes:
Code: Select all
<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 $attribute = $mechanical" sqf:fix="add_attribute_mechanical add_attribute_display">
The <name/> element should have a
<value-of select="$attrName"/> attribute.
</assert>
<sqf:fix id="add_attribute_mechanical">
<sqf:description>
<sqf:title>Adds the value <value-of select="$mechanical"/> to the @<value-of select="$attrName"/> attribute</sqf:title>
</sqf:description>
<sqf:add match="." node-type="attribute" target="platform">
<value-of select="$mechanical"/>
</sqf:add>
</sqf:fix>
<sqf:fix id="add_attribute_display">
<sqf:description>
<sqf:title>Adds the value <value-of select="$terminal"/> to the @<value-of select="$attrName"/> attribute</sqf:title>
</sqf:description>
<sqf:add match="." node-type="attribute" target="platform">
<value-of select="$terminal"/>
</sqf:add>
</sqf:fix>
</rule>
</pattern>
<pattern is-a="requiredAttribute">
<param name="context" value="xref[@format='dita' or not(@format)][not(@platform)]"/>
<param name="attribute" value="@platform"/>
<param name="attrName" value="'platform'"/>
<param name="terminal" value="'terminal'"/>
<param name="mechanical" value="'mechanical'"/>
</pattern>
</schema>
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
Return to “DITA (Editing and Publishing DITA Content)”
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ SDK-API, Frameworks - Document Types
- ↳ DocBook
- ↳ TEI
- ↳ XHTML
- ↳ Other Issues
- Oxygen XML Web Author
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Content Fusion
- ↳ Feature Request
- ↳ Common Problems
- Oxygen JSON Editor
- ↳ Feature Request
- ↳ Common Problems
- Oxygen PDF Chemistry
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Feedback
- ↳ Feature Request
- ↳ Common Problems
- Oxygen XML WebHelp
- ↳ Feature Request
- ↳ Common Problems
- XML
- ↳ General XML Questions
- ↳ XSLT and FOP
- ↳ XML Schemas
- ↳ XQuery
- NVDL
- ↳ General NVDL Issues
- ↳ oNVDL Related Issues
- XML Services Market
- ↳ Offer a Service