Skip to content

Commit

Permalink
Merge pull request qt4cg#1586 from michaelhkay/1527-rendition-of-name…
Browse files Browse the repository at this point in the history
…d-record-tyeps

1527 Move record types into separate sections
  • Loading branch information
ndw authored Nov 26, 2024
2 parents 765e55e + 0a004ee commit 79bc1bb
Show file tree
Hide file tree
Showing 3 changed files with 90 additions and 40 deletions.
35 changes: 22 additions & 13 deletions specifications/xpath-functions-40/src/function-catalog.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,19 @@
<fos:variable id="v-item3" name="item3" select="$po/line-item[3]"/>
</fos:global-variables>

<fos:record-type id="key-value-pair" extensible="true">
<fos:field name="key" type="xs:anyAtomicType" required="true">
<fos:meaning>
<p>A key suitable for use in a map entry.</p>
</fos:meaning>
</fos:field>
<fos:field name="value" type="item()*" required="true">
<fos:meaning>
<p>The value corresponding to the key.</p>
</fos:meaning>
</fos:field>
</fos:record-type>

<fos:record-type id="uri-structure-record" extensible="true">
<fos:field name="uri" type="xs:string?" required="false">
<fos:meaning>
Expand Down Expand Up @@ -23035,7 +23048,7 @@ return fold-left($maps, {},
<fos:signatures>
<fos:proto name="of-pairs" return-type="map(*)">
<fos:arg name="input"
type="record(key as xs:anyAtomicType, value as item()*)*"
type-ref="key-value-pair" type-ref-occurs="*"
usage="inspection"
example="{ 'key':'n','value':false() }, { 'key':'y','value':true() }"/>
<fos:arg name="combine" type="(fn(item()*, item()*) as item()*)?" usage="inspection" default="fn:op(',')"/>
Expand Down Expand Up @@ -23407,7 +23420,7 @@ return map:keys-where($birthdays, fn($name, $date) {

<fos:function name="pairs" prefix="map">
<fos:signatures>
<fos:proto name="pairs" return-type="record(key as xs:anyAtomicType, value as item()*)*">
<fos:proto name="pairs" return-type-ref="key-value-pair" return-type-ref-occurs="*">
<fos:arg name="map" type="map(*)" usage="inspection"/>
</fos:proto>
</fos:signatures>
Expand Down Expand Up @@ -23911,7 +23924,7 @@ map:merge(//book ! map:entry(isbn, .))]]></eg>

<fos:function name="pair" prefix="map">
<fos:signatures>
<fos:proto name="pair" return-type="record(key as xs:anyAtomicType, value as item()*)">
<fos:proto name="pair" return-type-ref="key-value-pair">
<fos:arg name="key" type="xs:anyAtomicType"/>
<fos:arg name="value" type="item()*" usage="navigation"/>
</fos:proto>
Expand Down Expand Up @@ -25943,10 +25956,8 @@ return json-to-xml($json, $options)]]></eg>
</fos:option>
</fos:options>

<p>The result of the function is a <code>parsed-csv-structure-record</code>, which is defined as
follows:</p>

<?record-description parsed-csv-structure-record?>
<p>The result of the function is a <code>parsed-csv-structure-record</code>, as
defined in <specref ref="parsed-csv-structure-record"/>.</p>



Expand Down Expand Up @@ -29739,9 +29750,7 @@ declare function array:flatten(


<p>The result of the function is a map
<var>R</var> with two entries:</p>

<?record-description load-xquery-module-record?>
<var>R</var> with two entries, as defined in <specref ref="load-xquery-module-record"/>.</p>


<p>The static and dynamic context of the library module are established according to the rules in
Expand Down Expand Up @@ -30643,9 +30652,9 @@ return $result?output//body
<fos:rules>
<p diff="chg" at="2022-12-19"
>The function returns a random number generator. A random number generator is represented as a value of type
<code>random-number-generator-record</code>, defined as follows:</p>

<?record-description random-number-generator-record?>
<code>random-number-generator-record</code>, defined in
<specref ref="random-number-generator-record"/>.</p>




Expand Down
32 changes: 27 additions & 5 deletions specifications/xpath-functions-40/src/xpath-functions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2538,6 +2538,11 @@ string conversion of the number as obtained above, and the appropriate <var>suff
<div2 id="random-numbers">
<head>Random Numbers</head>
<?local-function-index?>

<p>The function makes use of the record structure defined in the next section.</p>
<div3 id="random-number-generator-record">
<head><?record-description random-number-generator-record?></head>
</div3>
<div3 id="func-random-number-generator">
<head><?function fn:random-number-generator?></head>
</div3>
Expand Down Expand Up @@ -3535,11 +3540,12 @@ It is recommended that implementers consult <bibref ref="UNICODE-TR18"/> for inf

<?local-function-index?>

<p>The structured representation of a URI is described by the
<loc href="#uri-structure-record">uri-structure-record</loc>, whose parts are:</p>
<p>Both functions use a structured representation of a URI as defined in the next section.</p>

<?record-description uri-structure-record?>


<div3 id="uri-structure-record">
<head><?record-description uri-structure-record?></head>

<p>The segmented forms of the path and query parameters provide
convenient access to commonly used information.</p>

Expand All @@ -3564,6 +3570,7 @@ It is recommended that implementers consult <bibref ref="UNICODE-TR18"/> for inf
is repeated in the query string, the map will contain a
sequence of values for that key, as seen for <code>a</code>
in this example.</p>
</div3>

<div3 id="func-parse-uri">
<head><?function fn:parse-uri?></head>
Expand Down Expand Up @@ -7101,6 +7108,9 @@ Field 2A,Field 2B,Field 2C,Field 2D'



</div3>
<div3 id="parsed-csv-structure-record">
<head><?record-description parsed-csv-structure-record?></head>
</div3>
<div3 id="func-parse-csv">
<head><?function fn:parse-csv?></head>
Expand Down Expand Up @@ -7483,6 +7493,9 @@ return <table>
<p>The following functions allow dynamic loading and evaluation of XQuery queries, XSLT stylesheets,
and XPath binary operators.</p>
<?local-function-index?>
<div3 id="load-xquery-module-record">
<head><?record-description load-xquery-module-record?></head>
</div3>
<div3 id="func-load-xquery-module">
<head><?function fn:load-xquery-module?></head>
</div3>
Expand Down Expand Up @@ -7554,6 +7567,7 @@ return <table>
<item><p><termdef id="dt-key-value-pair-map" term="key-value pair map">A <term>key-value pair map</term> is a map containing two
entries, one (with the key <code>"key"</code>) containing the key part of a key value pair, the other (with the key <code>"value"</code>)
containing the value part of a key value pair.</termdef></p>
<p>The record type for a <termref def="dt-key-value-pair-map"/> is defined in <specref ref="key-value-pair"/>.</p>
<p>For example
the map <code>{ "x": 1, "y": 2 }</code> can be decomposed as
<code>({ "key": "x", "value": 1 }, { "key": "y", "value": 2 })</code></p>
Expand Down Expand Up @@ -7600,6 +7614,10 @@ return <table>
</tr>
</tbody>
</table>

<div3 id="key-value-pair">
<head><?record-description key-value-pair?></head>
</div3>

</div2>

Expand Down Expand Up @@ -9137,7 +9155,7 @@ return <table>
<p>The structured representation of a schema type is described by the
<loc href="#schema-type-record">schema-type-record</loc>, whose parts are:</p>

<?record-description schema-type-record?>
<p>?record-description schema-type-record?</p>

<note>
<p>Simple properties of a schema type that can be expressed as strings or booleans are
Expand All @@ -9156,6 +9174,10 @@ return <table>

<?local-function-index?>

<div3 id="schema-type-record">
<head><?record-description schema-type-record?></head>
</div3>

<div3 id="func-schema-type">
<head><?function fn:schema-type?></head>
</div3>
Expand Down
63 changes: 41 additions & 22 deletions specifications/xpath-functions-40/style/merge-function-specs.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -117,16 +117,6 @@
<def>
<xsl:copy-of select="$fspec/fos:signatures/(@diff, @at)"/>
<xsl:apply-templates select="$fspec/fos:signatures/fos:proto"/>
<xsl:for-each select="distinct-values($fspec/fos:signatures//(@type-ref|@return-type-ref))">
<xsl:call-template name="show-record-type">
<xsl:with-param name="name" select="."/>
<xsl:with-param name="definition" select="key('record-type', ., $fosdoc)"/>
<xsl:with-param name="is-first"
select="empty($fspec/preceding-sibling::fos:function[
fos:signatures//(@type-ref|@return-type-ref) = current()])"/>
</xsl:call-template>
</xsl:for-each>
<xsl:apply-templates select="$fspec/fos:signatures/fos:record"/>
</def>
</gitem>
<xsl:if test="$fspec/fos:properties">
Expand Down Expand Up @@ -235,6 +225,24 @@
</glist>
</xsl:template>

<xsl:template match="head[processing-instruction('record-description')]" expand-text="yes">
<xsl:variable name="lexname" select="processing-instruction('record-description')/normalize-space(.)"/>
<xsl:variable name="definition" select="$fosdoc/fos:functions/fos:record-type[@id = $lexname]"/>
<xsl:if test="empty($definition)">
<xsl:message terminate="yes">*** Record definition {$lexname} not found ***</xsl:message>
</xsl:if>
<head>Record fn:{$definition/@id}</head>
<xsl:apply-templates select="processing-instruction('record-description') (:$definition:)"/>
</xsl:template>

<xsl:template match="fos:record-type">
<xsl:call-template name="show-record-type">
<xsl:with-param name="name" select="@id"/>
<xsl:with-param name="definition" select="."/>
<xsl:with-param name="is-first" select="true()"/>
</xsl:call-template>
</xsl:template>

<xsl:function name="fos:use-two-column-format" as="xs:boolean">
<xsl:param name="examples" as="element(fos:examples)"/>
<xsl:sequence select="not(contains-token($examples/@role, 'wide'))
Expand Down Expand Up @@ -271,16 +279,19 @@
<xsl:param name="name" as="xs:string"/>
<xsl:param name="definition" as="element(fos:record-type)"/>
<xsl:param name="is-first" as="xs:boolean"/>
<eg>
<xsl:if test="$is-first">
<xsl:attribute name="id" select="$name"/>
</xsl:if>
<xsl:text>record {$name} (&#xa;</xsl:text>
<xsl:for-each select="$definition/fos:field">
<xsl:text> {@name}{if (xs:boolean(@required)) then "" else "?"} as {@type}{if (position() ne last()) then "," else ""}&#xa;</xsl:text>
</xsl:for-each>
<xsl:text>)&#xa;</xsl:text>
</eg>
<example role="record">
<record>
<xsl:if test="$is-first">
<xsl:attribute name="id" select="$name"/>
</xsl:if>
<!--<xsl:text>record {$name} (&#xa;</xsl:text>-->
<xsl:for-each select="$definition/fos:field">
<arg name="{@name}" type="{@type}" occur="{if (xs:boolean(@required)) then 'req' else 'opt'}"/>
<!--<xsl:text> {@name}{if (xs:boolean(@required)) then "" else "?"} as {@type}{if (position() ne last()) then "," else ""}&#xa;</xsl:text>-->
</xsl:for-each>
<!--<xsl:text>)&#xa;</xsl:text>-->
</record>
</example>
</xsl:template>

<xsl:template match="@dependency"> It depends on
Expand Down Expand Up @@ -555,7 +566,7 @@
</thead>
<tbody>
<xsl:for-each
select="following-sibling::*[starts-with(local-name(), 'div')][head/processing-instruction()]">
select="following-sibling::*[starts-with(local-name(), 'div')][head/processing-instruction('function')]">
<xsl:variable name="lexname" select="string(head/processing-instruction())"/>
<xsl:variable name="fspec"
select="fos:get-function(substring-before($lexname, ':'), substring-after($lexname, ':'))"/>
Expand All @@ -578,7 +589,8 @@
<xsl:template match="p[termdef[@role = 'placemarker']]"/>

<xsl:template match="processing-instruction(record-description)">
<xsl:variable name="target" select="key('record-type', string(.), $fosdoc)"/>
<xsl:variable name="record-name" select="normalize-space()"/>
<xsl:variable name="target" select="key('record-type', $record-name, $fosdoc)"/>
<xsl:if test="count($target) ne 1">
<xsl:message expand-text="yes">Failed to locate record type {.}</xsl:message>
</xsl:if>
Expand Down Expand Up @@ -616,6 +628,12 @@
</thead>
<tbody>
<xsl:apply-templates select="$record/fos:field" mode="narrative"/>
<xsl:if test="xs:boolean($record/@extensible)">
<tr>
<td><p><code>*</code></p></td>
<td><p>The record type is extensible (it may contain additional fields beyond those listed).</p></td>
</tr>
</xsl:if>
</tbody>
</table>

Expand Down Expand Up @@ -674,6 +692,7 @@
<p>
<code>
<xsl:value-of select="@key|@name"/>
<xsl:if test="not(xs:boolean(@required))">?</xsl:if>
</code>
</p>
</td>
Expand Down

0 comments on commit 79bc1bb

Please sign in to comment.