Skip to content

Commit

Permalink
Merge pull request #375 from w3c/gregorio-updates
Browse files Browse the repository at this point in the history
Implementing new function for array joining
  • Loading branch information
gregoriopellegrino authored Aug 19, 2024
2 parents 70bbe97 + 039fb47 commit bc88008
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 12 deletions.
Binary file not shown.
36 changes: 24 additions & 12 deletions UX-Guide-Metadata/draft/techniques/onix-metadata/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ <h3>Preprocessing</h3>
<ol class="condition">
<li><b>LET</b> <var>record</var> be textual representation of the ONIX record for the publication given <var>onix_record_as_text</var>.</li>
<li><b>LET</b> <var>onix</var> be the DOM tree that results from parsing <var>record</var> using an XML DOM parser.</li>
<li>Return <var>onix</var>.</li>
<li>return <var>onix</var>.</li>
</ol>
<aside class="note">
<p>The XML file being processed may contain namespaces, in the techniques when we use XPATH we will assume that the default namespace of the root record is used.</p>
Expand All @@ -183,6 +183,22 @@ <h3>Check for Node</h3>
<li><b>ELSE</b> return <code>False</code>.</li>
</ol>
</section>
<section id="join-array-to-comma-list">
<h3>Join array to comma list</h3>
<p>This function serves to concatenate an array of strings, separating each element with a comma, with the last element separated by an <code>", and"</code> (this string is localizable).</p>
<p>For example if the input array has elements <code>["one", "two", "three"]</code>, then the output is going to be <code>"one, two, and three"</code>.</p>
<p>This algorithm takes the <var>string_array</var> argument: the list of string to join.</p>
<p>To join the array, run the following steps:</p>
<ol class="condition">
<li><b>LET</b> <var>output_string</var> be the result of:
<ul class="condition">
<li>calling join on <var>string_array</var> with the separator <code>", "</code></li>
<li>replacing the last occurrence of <code>", "</code> with <code id="join-array-and">", and "</code>.</li>
</ul>
</li>
<li>return <var>output_string</var>.</li>
</ol>
</section>
</section>
<section id="techniques">
<h2>Techniques</h2>
Expand Down Expand Up @@ -637,8 +653,7 @@ <h4>Instructions</h4>
</li>
<li><b>LET</b> <var>navigation_string</var> be the result of:
<ul class="condition">
<li>calling join on <var>navigation</var> with the separator <code>", "</code></li>
<li>replacing the last occurrence of <code>", "</code> with <code id="join-array-and">", and "</code></li>
<li>calling <a href="#join-array-to-comma-list">join array to comma list</a> given <var>navigation</var></li>
<li>concatenating <code id="navigation-intro">"Navigation by "</code> to the beginning of the string.</li>
</ul>
</li>
Expand Down Expand Up @@ -825,9 +840,8 @@ <h4>Instructions</h4>
</li>
<li><b>LET</b> <var>hazards_string</var> be the result of:
<ul class="condition">
<li>calling join on <var>hazards</var> with the separator <code>", "</code></li>
<li>making uppercase the first character</li>
<li>replacing the last occurrence of <code>", "</code> with <code id="join-array-and">", and "</code></li>
<li>calling <a href="#join-array-to-comma-list">join array to comma list</a> given <var>hazards</var></li>
<li>uppercasing the first character</li>
<li>concatenating <code id="hazards-plural">" hazards"</code> to the end of the string <b>IF</b> (length of <var>hazards</var>) > 1 <b>ELSE</b> concatenating <code id="hazards-singular">" hazard"</code> to the end of the string.</li>
</ul>
</li>
Expand Down Expand Up @@ -1062,9 +1076,8 @@ <h5>Instructions</h5>
<ol class="condition">
<li><b>LET</b> <var>adaptation_string</var> be the result of:
<ul class="condition">
<li>calling join on <var>adaptation</var> with the separator <code>", "</code></li>
<li>making uppercase the first character</li>
<li>replacing the last occurrence of <code>", "</code> with <code id="join-array-and">", and "</code>.</li>
<li>calling <a href="#join-array-to-comma-list">join array to comma list</a> given <var>adaptation</var></li>
<li>uppercasing the first character.</li>
</ul>
</li>
<li>display <var>adaptation_string</var>.</li>
Expand Down Expand Up @@ -1162,9 +1175,8 @@ <h5>Instructions</h5>
<ol class="condition">
<li><b>LET</b> <var>clarity_string</var> be the result of:
<ul class="condition">
<li>calling join on <var>clarity</var> with the separator <code>", "</code></li>
<li>making uppercase the first character</li>
<li>replacing the last occurrence of <code>", "</code> with <code id="join-array-and">", and "</code>.</li>
<li>calling <a href="#join-array-to-comma-list">join array to comma list</a> given <var>clarity</var></li>
<li>uppercasing the first character.</li>
</ul>
</li>
<li>display <var>clarity_string</var>.</li>
Expand Down

0 comments on commit bc88008

Please sign in to comment.