- From: Dimitre Novatchev <dnovatchev@gmail.com>
- Date: Tue, 24 Oct 2023 15:00:11 -0700
- To: Michael Kay <mike@saxonica.com>
- Cc: public-xslt-40@w3.org, Norm Tovey-Walsh <norm@saxonica.com>, Dimitre Novatchev <dnovatchev@gmail.com>
- Message-ID: <CAK4KnZd_wfp5x4BaY80Lu3hi7m0qBGS87C7gW+LyN87iBg9Q-w@mail.gmail.com>
On Tue, Oct 24, 2023 at 2:47 PM Michael Kay <mike@saxonica.com> wrote: > As an alternative to fos:result, you can have (for example) > > <fos:error-result error-code="FOCV0004"/> > Thanks, and one hopefully last question: Can all <fos:variable> elements be specified preceding the <fos:examples> element, so that these variables could be shared by different examples? What would be the recommended place in the document for the set of <fos:variable> elements? Thanks, Dimitre > > Michael Kay > > On 24 Oct 2023, at 22:25, Dimitre Novatchev <dnovatchev@gmail.com> wrote: > > > and the fos:result should be valid XPath > > What should be the contents of fos:result in a case when the expected > result is that a (type) error should be raised? > > On Tue, Oct 24, 2023 at 1:03 PM Michael Kay <mike@saxonica.com> wrote: > >> [ ] QT4CG-051-06: MK to help DN with the markup in fn:chain >> examples. >> >> I'd suggest following the example markup used by fn:serialize or >> fn:transitive-closure. >> >> The <fos:example> element can enclose either a prose example or a >> testable example. Testable examples are preferred if at all possible! An >> example of a testable example is: >> >> <fos:example> >> <fos:test use="transitive-closure-data"> >> <fos:expression><eg>let $tc := >> transitive-closure($direct-reports) >> return $tc($data//person[@id="2"])/string(@id)</eg></fos:expression> >> <fos:result>("3", "4", "6", "7", "8")</fos:result> >> </fos:test> >> </fos:example> >> >> The "use" attribute is a reference to variables that the example uses, in >> this case: >> >> <fos:variable name="data" id="transitive-closure-data"> >> <![CDATA[document{<doc> >> <person id="0"/> >> <person id="1" manager="0"/> >> <person id="2" manager="0"/> >> <person id="3" manager="2"/> >> <person id="4" manager="2"/> >> <person id="5" manager="1"/> >> <person id="6" manager="3"/> >> <person id="7" manager="6"/> >> <person id="8" manager="6"/> >> </doc>}]]> >> </fos:variable> >> >> If you use multiple variables, I suspect the "use" attribute can be a >> whitespace-separated list. >> >> The fos:expression should be valid XQuery (but use XPath if possible), >> and the fos:result should be valid XPath. Both contain expressions that >> should be context-free (except for references to variables, as discussed) >> and the results of the two expressions should compare equal when compared >> with deep-equal(). The fos:result expression, by convention, should contain >> only "constants", but that can include things like calls to constructor >> functions. >> >> The example gets turned into a human-readable example in the spec, and >> also into a test case in app/fo-spec-examples.xml, for example in this case >> >> <test-case name="fo-test-fn-transitive-closure-001"> >> <description>Test case for fn:transitive-closure</description> >> <created by="Michael Kay using generate-qt3-test-set.xsl" on= >> "2023-10-18"/> >> <environment ref="global"/> >> <dependency type="spec" value="XQ40+" satisfied="true"/> >> <test> >> let $data := >> document{<doc> >> <person id="0"/> >> <person id="1" manager="0"/> >> <person id="2" manager="0"/> >> <person id="3" manager="2"/> >> <person id="4" manager="2"/> >> <person id="5" manager="1"/> >> <person id="6" manager="3"/> >> <person id="7" manager="6"/> >> <person id="8" manager="6"/> >> </doc>} >> >> return >> >> >> let $tc := transitive-closure($direct-reports) >> return $tc($data//person[@id="2"])/string(@id) >> </test> >> <result> >> <assert-deep-eq>("3", "4", "6", "7", "8")</assert-deep-eq> >> </result> >> </test-case> >> >> >> Michael Kay >> Saxonica >> >> >> > > > >
Received on Tuesday, 24 October 2023 22:00:29 UTC