Schematron quick fix to add and element and an attribute
Posted: Wed Oct 26, 2022 7:15 pm
Hi,
I think I am trying to do something simple with Schematron and quick fixes but struggling.
I want to check for a given element and if it doesn't exist, then I want to add it and its required attribute.
I know I need
to add the missing element (resourceid) but not sure how I also add the required attribute name and value (appname="abc") in the same fix.
Any advice appreciated,
Regards,
Ann
I think I am trying to do something simple with Schematron and quick fixes but struggling.
I want to check for a given element and if it doesn't exist, then I want to add it and its required attribute.
I know I need
Code: Select all
<sch:rule context="prolog">
<sch:assert test="resourceid" sqf:fix="addResource">ResourceId element is missing. </sch:assert>
<sqf:fix id="addResource">
<sqf:description><sqf:title>Add resourceId inside prolog</sqf:title></sqf:description>
<sqf:add target="resourceid" node-type="element" position="last-child"></sqf:add>
</sqf:fix>
</sch:rule>
to add the missing element (resourceid) but not sure how I also add the required attribute name and value (appname="abc") in the same fix.
Any advice appreciated,
Regards,
Ann