Skip to content

Commit

Permalink
changed: updated docs and version
Browse files Browse the repository at this point in the history
  • Loading branch information
MartijnR committed Sep 12, 2019
1 parent acfa383 commit ce000fe
Show file tree
Hide file tree
Showing 8 changed files with 74 additions and 44 deletions.
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).

[Unreleased]
[1.8.0] - 2019-09-12
---------------------
##### Added
- Check for duplicate question/group names (warning).
- Check for nested repeats (warning).

[1.7.0]
[1.7.0] - 2019-08-02
---------------------
##### Added
- Check for missing label elements.
Expand Down
52 changes: 26 additions & 26 deletions docs/XForm.html
Original file line number Diff line number Diff line change
Expand Up @@ -763,7 +763,7 @@ <h4 class="name" id="_cleanXmlDomParserError"><span class="type-signature"></spa

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="xform.js.html">xform.js</a>, <a href="xform.js.html#line550">line 550</a>
<a href="xform.js.html">xform.js</a>, <a href="xform.js.html#line577">line 577</a>
</li></ul></dd>


Expand Down Expand Up @@ -920,7 +920,7 @@ <h4 class="name" id="_cleanXPathException"><span class="type-signature"></span>_

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="xform.js.html">xform.js</a>, <a href="xform.js.html#line564">line 564</a>
<a href="xform.js.html">xform.js</a>, <a href="xform.js.html#line591">line 591</a>
</li></ul></dd>


Expand Down Expand Up @@ -1077,7 +1077,7 @@ <h4 class="name" id="_extractModelStr"><span class="type-signature"></span>_extr

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="xform.js.html">xform.js</a>, <a href="xform.js.html#line489">line 489</a>
<a href="xform.js.html">xform.js</a>, <a href="xform.js.html#line516">line 516</a>
</li></ul></dd>


Expand Down Expand Up @@ -1190,7 +1190,7 @@ <h4 class="name" id="_getDom"><span class="type-signature"></span>_getDom<span c

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="xform.js.html">xform.js</a>, <a href="xform.js.html#line499">line 499</a>
<a href="xform.js.html">xform.js</a>, <a href="xform.js.html#line526">line 526</a>
</li></ul></dd>


Expand Down Expand Up @@ -1295,7 +1295,7 @@ <h4 class="name" id="_getExternalDummyContent"><span class="type-signature"></sp

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="xform.js.html">xform.js</a>, <a href="xform.js.html#line457">line 457</a>
<a href="xform.js.html">xform.js</a>, <a href="xform.js.html#line484">line 484</a>
</li></ul></dd>


Expand Down Expand Up @@ -1400,7 +1400,7 @@ <h4 class="name" id="_getWindow"><span class="type-signature"></span>_getWindow<

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="xform.js.html">xform.js</a>, <a href="xform.js.html#line436">line 436</a>
<a href="xform.js.html">xform.js</a>, <a href="xform.js.html#line463">line 463</a>
</li></ul></dd>


Expand Down Expand Up @@ -1548,7 +1548,7 @@ <h4 class="name" id="_nodeName"><span class="type-signature"></span>_nodeName<sp

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="xform.js.html">xform.js</a>, <a href="xform.js.html#line539">line 539</a>
<a href="xform.js.html">xform.js</a>, <a href="xform.js.html#line566">line 566</a>
</li></ul></dd>


Expand Down Expand Up @@ -1706,7 +1706,7 @@ <h4 class="name" id="_stripJrChoiceName"><span class="type-signature"></span>_st

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="xform.js.html">xform.js</a>, <a href="xform.js.html#line475">line 475</a>
<a href="xform.js.html">xform.js</a>, <a href="xform.js.html#line502">line 502</a>
</li></ul></dd>


Expand Down Expand Up @@ -1866,7 +1866,7 @@ <h4 class="name" id="_withFormControl"><span class="type-signature"></span>_with

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="xform.js.html">xform.js</a>, <a href="xform.js.html#line515">line 515</a>
<a href="xform.js.html">xform.js</a>, <a href="xform.js.html#line542">line 542</a>
</li></ul></dd>


Expand Down Expand Up @@ -2020,7 +2020,7 @@ <h4 class="name" id="_withoutFormControl"><span class="type-signature"></span>_w

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="xform.js.html">xform.js</a>, <a href="xform.js.html#line529">line 529</a>
<a href="xform.js.html">xform.js</a>, <a href="xform.js.html#line556">line 556</a>
</li></ul></dd>


Expand Down Expand Up @@ -2174,7 +2174,7 @@ <h4 class="name" id="checkAppearances"><span class="type-signature"></span>check

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="xform.js.html">xform.js</a>, <a href="xform.js.html#line342">line 342</a>
<a href="xform.js.html">xform.js</a>, <a href="xform.js.html#line369">line 369</a>
</li></ul></dd>


Expand Down Expand Up @@ -2333,7 +2333,7 @@ <h4 class="name" id="checkBinds"><span class="type-signature"></span>checkBinds<

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="xform.js.html">xform.js</a>, <a href="xform.js.html#line322">line 322</a>
<a href="xform.js.html">xform.js</a>, <a href="xform.js.html#line349">line 349</a>
</li></ul></dd>


Expand Down Expand Up @@ -2492,7 +2492,7 @@ <h4 class="name" id="checkOpenClinicaRules"><span class="type-signature"></span>

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="xform.js.html">xform.js</a>, <a href="xform.js.html#line405">line 405</a>
<a href="xform.js.html">xform.js</a>, <a href="xform.js.html#line432">line 432</a>
</li></ul></dd>


Expand Down Expand Up @@ -4088,7 +4088,7 @@ <h4 class="name" id="_cleanXmlDomParserError"><span class="type-signature"></spa

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="xform.js.html">xform.js</a>, <a href="xform.js.html#line550">line 550</a>
<a href="xform.js.html">xform.js</a>, <a href="xform.js.html#line577">line 577</a>
</li></ul></dd>


Expand Down Expand Up @@ -4245,7 +4245,7 @@ <h4 class="name" id="_cleanXPathException"><span class="type-signature"></span>_

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="xform.js.html">xform.js</a>, <a href="xform.js.html#line564">line 564</a>
<a href="xform.js.html">xform.js</a>, <a href="xform.js.html#line591">line 591</a>
</li></ul></dd>


Expand Down Expand Up @@ -4402,7 +4402,7 @@ <h4 class="name" id="_extractModelStr"><span class="type-signature"></span>_extr

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="xform.js.html">xform.js</a>, <a href="xform.js.html#line489">line 489</a>
<a href="xform.js.html">xform.js</a>, <a href="xform.js.html#line516">line 516</a>
</li></ul></dd>


Expand Down Expand Up @@ -4515,7 +4515,7 @@ <h4 class="name" id="_getDom"><span class="type-signature"></span>_getDom<span c

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="xform.js.html">xform.js</a>, <a href="xform.js.html#line499">line 499</a>
<a href="xform.js.html">xform.js</a>, <a href="xform.js.html#line526">line 526</a>
</li></ul></dd>


Expand Down Expand Up @@ -4620,7 +4620,7 @@ <h4 class="name" id="_getExternalDummyContent"><span class="type-signature"></sp

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="xform.js.html">xform.js</a>, <a href="xform.js.html#line457">line 457</a>
<a href="xform.js.html">xform.js</a>, <a href="xform.js.html#line484">line 484</a>
</li></ul></dd>


Expand Down Expand Up @@ -4725,7 +4725,7 @@ <h4 class="name" id="_getWindow"><span class="type-signature"></span>_getWindow<

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="xform.js.html">xform.js</a>, <a href="xform.js.html#line436">line 436</a>
<a href="xform.js.html">xform.js</a>, <a href="xform.js.html#line463">line 463</a>
</li></ul></dd>


Expand Down Expand Up @@ -4873,7 +4873,7 @@ <h4 class="name" id="_nodeName"><span class="type-signature"></span>_nodeName<sp

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="xform.js.html">xform.js</a>, <a href="xform.js.html#line539">line 539</a>
<a href="xform.js.html">xform.js</a>, <a href="xform.js.html#line566">line 566</a>
</li></ul></dd>


Expand Down Expand Up @@ -5031,7 +5031,7 @@ <h4 class="name" id="_stripJrChoiceName"><span class="type-signature"></span>_st

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="xform.js.html">xform.js</a>, <a href="xform.js.html#line475">line 475</a>
<a href="xform.js.html">xform.js</a>, <a href="xform.js.html#line502">line 502</a>
</li></ul></dd>


Expand Down Expand Up @@ -5191,7 +5191,7 @@ <h4 class="name" id="_withFormControl"><span class="type-signature"></span>_with

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="xform.js.html">xform.js</a>, <a href="xform.js.html#line515">line 515</a>
<a href="xform.js.html">xform.js</a>, <a href="xform.js.html#line542">line 542</a>
</li></ul></dd>


Expand Down Expand Up @@ -5345,7 +5345,7 @@ <h4 class="name" id="_withoutFormControl"><span class="type-signature"></span>_w

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="xform.js.html">xform.js</a>, <a href="xform.js.html#line529">line 529</a>
<a href="xform.js.html">xform.js</a>, <a href="xform.js.html#line556">line 556</a>
</li></ul></dd>


Expand Down Expand Up @@ -5499,7 +5499,7 @@ <h4 class="name" id="checkAppearances"><span class="type-signature"></span>check

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="xform.js.html">xform.js</a>, <a href="xform.js.html#line342">line 342</a>
<a href="xform.js.html">xform.js</a>, <a href="xform.js.html#line369">line 369</a>
</li></ul></dd>


Expand Down Expand Up @@ -5658,7 +5658,7 @@ <h4 class="name" id="checkBinds"><span class="type-signature"></span>checkBinds<

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="xform.js.html">xform.js</a>, <a href="xform.js.html#line322">line 322</a>
<a href="xform.js.html">xform.js</a>, <a href="xform.js.html#line349">line 349</a>
</li></ul></dd>


Expand Down Expand Up @@ -5817,7 +5817,7 @@ <h4 class="name" id="checkOpenClinicaRules"><span class="type-signature"></span>

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="xform.js.html">xform.js</a>, <a href="xform.js.html#line405">line 405</a>
<a href="xform.js.html">xform.js</a>, <a href="xform.js.html#line432">line 432</a>
</li></ul></dd>


Expand Down
9 changes: 6 additions & 3 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ <h3> </h3>


<section class="readme">
<article><p><img src="https://img.shields.io/badge/coverage-89.96%25-brightgreen.svg" alt="coverage-shield-badge-1">
<article><p><img src="https://img.shields.io/badge/coverage-97.24%25-brightgreen.svg" alt="coverage-shield-badge-1">
<a href="http://badge.fury.io/js/enketo-validate"><img src="https://badge.fury.io/js/enketo-validate.svg" alt="npm version"></a> <a href="https://travis-ci.org/enketo/enketo-validate"><img src="https://travis-ci.org/enketo/enketo-validate.svg?branch=master" alt="Build Status"></a> <a href="https://david-dm.org/enketo/enketo-validate"><img src="https://david-dm.org/enketo/enketo-validate/status.svg" alt="Dependency Status"></a> <a href="https://david-dm.org/enketo/enketo-validate?type=dev"><img src="https://david-dm.org/enketo/enketo-validate/dev-status.svg" alt="devDependency Status"></a></p>
<h1 id="enketo-validate">Enketo Validate</h1>
<p><em>Validate <a href="https://opendatakit.github.io/xforms-spec/">ODK XForms</a> using Enketo's form engine</em></p>
Expand Down Expand Up @@ -122,11 +122,14 @@ <h2 id="how-it-works">How it works</h2>
<p>In it's current iteration, the validator does the following:</p>
<ul>
<li>It checks whether the XForm is a valid XML document.</li>
<li>It performs some basic ODK XForm structure checks.</li>
<li>It performs some elementary ODK XForm structure checks.</li>
<li>It checks if each bind <code>nodeset</code> exists in the primary instance.</li>
<li>It checks if appearance values are supported for that type of question.</li>
<li>It checks if appearance values are supported or deprecated for that type of question.</li>
<li>It checks for each <code>&lt;bind&gt;</code> whether the <code>relevant</code>, <code>constraint</code>, <code>calculate</code>, and <code>required</code> expressions are supported and valid* XPath.</li>
<li>It checks whether required <code>&lt;label&gt;</code> elements exist.</li>
<li>It checks for duplicate question or group names.</li>
<li>It checks for nested repeats.</li>
<li>It checks for form controls that have a calculation but are not set as readonly.</li>
</ul>
<p>* Note, that <code>/path/to/nonexisting/node</code> is perfectly valid XPath.</p>
<h2 id="funding">Funding</h2>
Expand Down
6 changes: 3 additions & 3 deletions docs/module-utils.html
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ <h1 class="page-title">utils</h1>

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="utils.js.html">utils.js</a>, <a href="utils.js.html#line4">line 4</a>
<a href="utils.js.html">utils.js</a>, <a href="utils.js.html#line5">line 5</a>
</li></ul></dd>


Expand Down Expand Up @@ -173,7 +173,7 @@ <h4 class="name" id=".addXPathExtensionsOc"><span class="type-signature">(static

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="utils.js.html">utils.js</a>, <a href="utils.js.html#line19">line 19</a>
<a href="utils.js.html">utils.js</a>, <a href="utils.js.html#line20">line 20</a>
</li></ul></dd>


Expand Down Expand Up @@ -249,7 +249,7 @@ <h4 class="name" id=".parseFunctionFromExpression"><span class="type-signature">

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="utils.js.html">utils.js</a>, <a href="utils.js.html#line14">line 14</a>
<a href="utils.js.html">utils.js</a>, <a href="utils.js.html#line15">line 15</a>
</li></ul></dd>


Expand Down
7 changes: 4 additions & 3 deletions docs/utils.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ <h1 class="page-title">utils.js</h1>
<section>
<article>
<pre class="prettyprint source linenums"><code>import { parseFunctionFromExpression } from 'enketo-core/src/js/utils';
import { getXPath } from 'enketo-core/src/js/dom-utils';
import addXPathExtensionsOc from 'enketo-xpath-extensions-oc';

/**
Expand All @@ -65,9 +66,9 @@ <h1 class="page-title">utils.js</h1>
* @type function
* @see {@link https://github.com/OpenClinica/enketo-xpath-extensions-oc|addXPathExtensionsOc}
*/
addXPathExtensionsOc
};
</code></pre>
addXPathExtensionsOc,
getXPath
};</code></pre>
</article>
</section>

Expand Down
36 changes: 31 additions & 5 deletions docs/xform.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -341,22 +341,49 @@ <h1 class="page-title">xform.js</h1>
if ( primInstanceEl ) {
const children = primInstanceEl.children;
if ( children.length === 0 ) {
errors.push( 'Primary instance element has child.' );
errors.push( 'Primary instance element has no child.' );
} else if ( children.length > 1 ) {
errors.push( 'Primary instance element has more than 1 child.' );
}
if ( children &amp;&amp; !children[ 0 ].id ) {
errors.push( `Data root node &lt;${children[0].nodeName}> has no id attribute.` );
}
if ( children &amp;&amp; children[ 0 ] ) {
const dataNodeNames = [];
const dataNodes = children[ 0 ].querySelectorAll( '*' );

dataNodes.forEach( el => {
const nodeName = el.nodeName;
const index = dataNodeNames.indexOf( nodeName );
// Save XPath determination for when necessary, to not negatively affect performance.
if ( index !== -1 &amp;&amp; utils.getXPath( dataNodes[ index ], 'instance' ) !== utils.getXPath( el, 'instance' ) ) {
warnings.push( `Duplicate question or group name "${nodeName}" found. Unique names are recommended` );
}
dataNodeNames.push( nodeName );
} );
}
}

if ( this.repeats.length ) {
const repeatPaths = [];
this.repeats.reverse().forEach( repeat => {
const nodeset = repeat.getAttribute( 'nodeset' );
// This check will fail if relative nodesets are used (not supported in Enketo any more).
if ( repeatPaths.some( repeatPath => repeatPath.startsWith( nodeset ) ) ) {
const name = nodeset.substring( nodeset.lastIndexOf( '/' ) + 1 );
warnings.push( `Repeat "${name}" contains a nested repeat. This not recommended.` );
}
repeatPaths.push( nodeset );
} );
}

// ODK Build bug
if ( this.doc.querySelector( 'group:not([ref])' ) ) {
if ( bodyEl &amp;&amp; bodyEl.querySelector( 'group:not([ref])' ) ) {
warnings.push( 'Found &lt;group> without ref attribute. This might be fine as long as the group has no relevant logic.' );
}

// ODK Build output
if ( this.doc.querySelector( 'group:not([ref]) > repeat' ) ) {
if ( bodyEl &amp;&amp; bodyEl.querySelector( 'group:not([ref]) > repeat' ) ) {
warnings.push( 'Found &lt;repeat> that has a parent &lt;group> without a ref attribute. ' +
'If the repeat has relevant logic, this will make the form very slow.' );
}
Expand Down Expand Up @@ -629,8 +656,7 @@ <h1 class="page-title">xform.js</h1>

module.exports = {
XForm: XForm
};
</code></pre>
};</code></pre>
</article>
</section>

Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit ce000fe

Please sign in to comment.