Skip to content

Commit

Permalink
Issue #5 : add 2 Schematron Quick Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
mricaud committed May 6, 2021
1 parent f24e4f7 commit 826179d
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 10 deletions.
27 changes: 26 additions & 1 deletion src/main/sch/modules/xslt-quality_typing.sch
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xd="http://www.oxygenxml.com/ns/doc/xsl"
xmlns:sqf="http://www.schematron-quickfix.com/validator/process"
xml:lang="en"
id="xslt-quality_typing">

Expand All @@ -19,9 +20,33 @@
</xd:doc>
<report id="xslt-quality_typing-with-as-attribute"
test="$xslt.version = ('2.0', '3.0') and not(@as)"
diagnostics="addType">
sqf:fix="sqf_add-empty-as-attribute sqf_add-xsString-as-attribute">
<name/> is not typed
</report>
</rule>

<sqf:fixes>
<sqf:fix id="sqf_add-empty-as-attribute">
<sqf:description>
<sqf:title xml:lang="en">Add "as" attribute</sqf:title>
<!--<sqf:title xml:lang="fr">Ajouter un attribut "as"</sqf:title>-->
</sqf:description>
<sqf:user-entry name="type">
<sqf:description>
<sqf:title>Enter a type for "as" attribute:</sqf:title>
</sqf:description>
</sqf:user-entry>
<sqf:add match="." target="as" node-type="attribute">
<value-of select="$type"/>
</sqf:add>
</sqf:fix>
<sqf:fix id="sqf_add-xsString-as-attribute">
<sqf:description>
<sqf:title xml:lang="en">Add "as" attribute with value "xs:string"</sqf:title>
<!--<sqf:title xml:lang="fr">Ajouter un attribut "as"</sqf:title>-->
</sqf:description>
<sqf:add match="." target="as" node-type="attribute">xs:string</sqf:add>
</sqf:fix>
</sqf:fixes>

</pattern>
14 changes: 13 additions & 1 deletion src/main/sch/modules/xslt-quality_writing.sch
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xd="http://www.oxygenxml.com/ns/doc/xsl"
xmlns:sqf="http://www.schematron-quickfix.com/validator/process"
xml:lang="en"
id="xslt-quality_writing">

Expand All @@ -18,9 +19,20 @@
<xd:desc xml:lang="fr">Si vous n'avez pas besoin d'instruction XSLT spécifiques pour calculer une variable, un paramètre (ou tout autre attribut, namespace) utilisez la syntaxe rapide "select=" qui rendra votre code moins verbeux et plus facile à lire.</xd:desc>
</xd:doc>
<report id="xslt-quality_use-select-attribute-when-possible"
test="not(@select) and (count(* | text()[normalize-space(.)]) = 1) and (count(xsl:value-of | xsl:sequence | text()[normalize-space(.)]) = 1)">
test="not(@select) and (count(* | text()[normalize-space(.)]) = 1) and (count(xsl:value-of | xsl:sequence | text()[normalize-space(.)]) = 1)"
sqf:fix="sqf_move-text-to-select-attribute">
Use @select to assign a value to <name/>
</report>
</rule>

<sqf:fixes>
<sqf:fix id="sqf_move-text-to-select-attribute">
<sqf:description>
<sqf:title xml:lang="en">Move the text content to a "select" attribute</sqf:title>
</sqf:description>
<sqf:add match="." target="select" node-type="attribute">'<value-of select="."/>'</sqf:add>
<sqf:delete match="./text()"/>
</sqf:fix>
</sqf:fixes>

</pattern>
8 changes: 0 additions & 8 deletions src/main/sch/xslt-quality.sch
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,6 @@

<xsl:variable name="xslt-quality_xslt-is-a-library" select="xslq:get-param-value('xslt-quality_xslt-is-a-library', '0', 'xs:boolean')" as="item()?"/>

<!--====================================-->
<!-- DIAGNOSTICS -->
<!--====================================-->

<diagnostics>
<diagnostic id="addType">Add @as attribute</diagnostic>
</diagnostics>

<!--====================================-->
<!-- INCLUSIONS -->
<!--====================================-->
Expand Down

0 comments on commit 826179d

Please sign in to comment.