-
Notifications
You must be signed in to change notification settings - Fork 4
/
xslt-quality_common.sch
44 lines (40 loc) · 2.32 KB
/
xslt-quality_common.sch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?xml version="1.0" encoding="UTF-8"?>
<pattern xmlns="http://purl.oclc.org/dsdl/schematron"
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:saxon="http://saxon.sf.net/"
xml:lang="en"
id="xslt-quality_common">
<xd:doc>
<xd:desc>
<xd:p>These rules are common XSLT checks that doesn't belong to other category (documentation, namespaces, typing, etc.)</xd:p>
</xd:desc>
</xd:doc>
<rule context="xsl:for-each">
<xd:doc>
<xd:desc xml:lang="en">Using xsl:for-each on nodes may be a clue of procedural programming. XSLT is rather a rule-programming language, data-driven. You should maybe consider using xsl:apply-templates instead</xd:desc>
<xd:desc xml:lang="fr">l'utilisation de xsl:for-each sur des nœuds peut être un indice de programmation procedural. XSLT est un langage de règles dirigé par les données. Vous devriez peut-être considéré l'utilisation de xsl:apply-templates à la place.</xd:desc>
</xd:doc>
<report id="xslt-quality_avoid-for-each"
test="ancestor::xsl:template
and not(starts-with(@select, '$'))
and not(starts-with(@select, 'tokenize('))
and not(starts-with(@select, 'distinct-values('))
and not(starts-with(@select, 'string-to-codepoints('))
and not(matches(@select, '\d'))"
role="warning">
Should you use xsl:apply-template instead of xsl:for-each
</report>
</rule>
<rule context="xsl:template/@match | xsl:*/@select | xsl:*/@test">
<xd:doc>
<xd:desc xml:lang="en">Using concatenation to resolve URI is not generic (windows and linux path are not the same) - Consider unsing the on-purpose resolve-uri() function instead</xd:desc>
<xd:desc xml:lang="fr">la concaténation de chaînes de caractère pour résoudre une URI n'est pas générique (les chemins sous Windows et Linux ne sont pas les mêmes) - Considérez plutôt l'utilisation de la fonction dédiée resolve-uri()</xd:desc>
</xd:doc>
<report id="xslt-quality_use-resolve-uri-instead-of-concat"
test="contains(., 'document(concat(') or contains(., 'doc(concat(')">
Avoid using concat within document() or doc() function, use resolve-uri() instead (you may use static-base-uri() or base-uri())
</report>
</rule>
</pattern>