Skip to content

Commit

Permalink
Minimise the number of replace operations.
Browse files Browse the repository at this point in the history
  • Loading branch information
georgebina committed Apr 3, 2017
1 parent 0e141cb commit 1d00cae
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions frameworks/legaldocml/schemas/rules.sch
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@
The current article number must be 'Article <sch:value-of select="$expectedNum"/>'
</sch:assert>

<!--<sch:assert test="matches(text(), '\s*Article\s*(\d+)\s*')">
The format must be "Article N" where "N" is the actual article number.
</sch:assert>-->

<sqf:fix id="correctNumber" use-when="text()">
<sqf:description>
<sqf:title>Set the article number to 'Article <sch:value-of select="$expectedNum"/>'</sqf:title>
Expand All @@ -37,7 +33,8 @@
<sqf:description>
<sqf:title>Correct all article numbers for the current bill.</sqf:title>
</sqf:description>
<sqf:replace match="(preceding::leg:article/leg:num, ., following::leg:article/leg:num)[generate-id(ancestor::leg:bill) eq $billID]/text()"
<sqf:replace match="(preceding::leg:article/leg:num, ., following::leg:article/leg:num)[generate-id(ancestor::leg:bill) eq $billID]/text()
[.!=concat('Article ', count(preceding::leg:article[generate-id(ancestor::leg:bill) eq $billID]/leg:num) + 1)]"
select="concat('Article ', count(preceding::leg:article[generate-id(ancestor::leg:bill) eq $billID]/leg:num) + 1)"/>
<sqf:add match="(preceding::leg:article/leg:num, ., following::leg:article/leg:num)[generate-id(ancestor::leg:bill) eq $billID][not(node())]"
select="concat('Article ', count(preceding::leg:article[generate-id(ancestor::leg:bill) eq $billID]/leg:num) + 1)"/>
Expand Down

0 comments on commit 1d00cae

Please sign in to comment.