Re: Whose error is it anyway

Ihe Onwuka <[email protected]>
Newsgroups gmane.text.xml.saxon.help
Message-ID <CALfs7+xbBzLQf9BD8urGdj9Ghz0NFN2N8DZY4HFctL3PoveYEA@mail.gmail.com>
So am losing track of exactly what situations lead to what error but here
is a clue

This error here was cleaned up by correcting the type declaration on the
map to allow the value to contain a sequence of strings.

Now is what you have below what you want to be putting out in response to
what is in effect a run time detection of a typing error. I don't think so.

 XTTE0570  An error occurred matching pattern {element()[let $action :=
  first(tokenize(convertUntyped(data(.)), "\s|-", "")) return
((matches($action, "\i\c*",
  "")) and (Q{http://www.w3.org/2005/xpath-functions/map}contains($actions,
  exactly-one($action))))]}:

On Sat, Aug 15, 2020 at 7:25 PM Ihe Onwuka <[email protected]> wrote:

> There is a type declaration of map(xs:string,xs:string) on the map
> $actions. So if a zero length key or value showed up..........
>
> On Sat, Aug 15, 2020 at 3:43 PM Ihe Onwuka <[email protected]> wrote:
>
>> The value of $action as at time of error contained a forward slash.
>>
>> I can recreate and answer any other questions that may follow now.
>>
>> On Fri, Aug 14, 2020 at 5:09 PM Trevor Nash <[email protected]> wrote:
>>
>>> Does the inconsistency with \W and \s mean that
>>> {map:get($actions,$action)} could evaluate to empty exactly as the (second)
>>> error message suggests?  In other words the match expression does not
>>> guarantee that $action is found in the map.
>>>
>>> Trevor
>>> On 14/08/2020 13:54, Ihe Onwuka wrote:
>>>
>>> I have since changed the code but this is the rest of the template rule
>>> but trying to reconstruct it
>>>
>>> <xsl:template
>>> match="*[map:contains($actions,tokenize(.,'\W')[1][matches(.,'\i\c*')])]">
>>>       <xsl:variable name="action" as="xs:string+"
>>> select="tokenize(.,'\s')[1]"/>
>>>       <xsl:copy>
>>>          <xsl:variable name="encodedAction">
>>>              <xsl:element
>>> name="{map:get($actions,$action)}">{normalize-space(substring-after(.,$action))}</xsl:element>
>>>          </xsl:variable>
>>>          <xsl:apply-templates select="$encodedAction"/>
>>>       </xsl:copy>
>>>    </xsl:template>
>>>
>>> Note an error I overlooked - the first tokenize used '\W' and the second
>>> '\s' which led to the situation.
>>>
>>> I wasn't going to mention this but now that I have pasted the whole code
>>> when I corrected the 2nd tokenize to '\W'  the transform threw a bash shell
>>> error (invalid fork argument)
>>>
>>>
>>>
>>>
>>> On Fri, Aug 14, 2020 at 8:46 AM Ihe Onwuka <[email protected]> wrote:
>>>
>>>> line 67
>>>> <xsl:element
>>>> name="{map:get($actions,$action)}">{normalize-space(substring-after(.,$action))}</xsl:element>
>>>>
>>>> where the @name did not evaluate to a valid XML name.
>>>>
>>>> On Fri, Aug 14, 2020 at 8:20 AM Michael Kay <mike-JkSD5nQpfvpWk0Htik3J/[email protected]> wrote:
>>>>
>>>>> What's on line 67? Is it the declaration of global variable $actions?
>>>>> Otherwise, I can't see why evaluating this pattern should result in a call
>>>>> on xsl:element.
>>>>>
>>>>> Michael Kay
>>>>> Saxonica
>>>>>
>>>>> On 14 Aug 2020, at 13:04, Ihe Onwuka <[email protected]> wrote:
>>>>>
>>>>> Happened again.
>>>>>
>>>>> My code. <xsl:template
>>>>> match="*[map:contains($actions,tokenize(.,'\W')[1][matches(.,'\i\c*')])]">
>>>>>
>>>>> Clearly it doesn't like the zero length string.
>>>>>
>>>>> Warning at char 1 in xsl:template/@match on line 63 column 92 of
>>>>> *****.xsl:
>>>>>   XPTY0004  An error occurred matching pattern
>>>>>   {element()[Q{
>>>>> http://www.w3.org/2005/xpath-functions/map}contains($actions,
>>>>>   exactly-one((first(tokenize(convertUntyped(data(.)), "\W",
>>>>> "")))[matches(., "\i\c*", "")]))]}:
>>>>> Error at char 9 in expression in xsl:element/@name on line 67 column
>>>>> 55 of ******.xsl:
>>>>>   XTDE0820  Supplied element name is a zero-length string
>>>>>
>>>>> On Thu, Aug 13, 2020 at 6:40 PM Ihe Onwuka <[email protected]>
>>>>> wrote:
>>>>>
>>>>>> I tried but cannot reconstruct a snippet that reproduces. The hint as
>>>>>> to what happened in my use case was the best I could offer.
>>>>>>
>>>>>> On Thu, Aug 13, 2020 at 6:15 PM Michael Kay <mike-JkSD5nQpfvpWk0Htik3J/[email protected]>
>>>>>> wrote:
>>>>>>
>>>>>>> If you post a repro that we can run, that's useful as we can examine
>>>>>>> the error messages, see what's causing them, and test any improvements.
>>>>>>> With only snippets like this, there's not really any effective action we
>>>>>>> can take.
>>>>>>>
>>>>>>> Michael Kay
>>>>>>> Saxonica
>>>>>>>
>>>>>>> On 13 Aug 2020, at 18:53, Ihe Onwuka <[email protected]> wrote:
>>>>>>>
>>>>>>> I can tell you that the error went away when I eliminated the
>>>>>>> possibility of the context element being empty. I struggle to correlate
>>>>>>> that back to the error message that was displayed.
>>>>>>>
>>>>>>> On Thu, Aug 13, 2020 at 10:16 AM Graydon <[email protected]>
>>>>>>> wrote:
>>>>>>>
>>>>>>>> Both?  The hints about what the optimizer thinks is happening are
>>>>>>>> useful right up until I can't tell where the error is.
>>>>>>>>
>>>>>>>> On August 13, 2020 1:40:48 PM UTC, Michael Kay <mike-JkSD5nQpfvpWk0Htik3J/[email protected]>
>>>>>>>> wrote:
>>>>>>>> >Yes, we should probably retain the original pattern as a string
>>>>>>>> rather
>>>>>>>> >than trying to reconstitute it from the compiled form.
>>>>>>>> >
>>>>>>>> >Michael Kay
>>>>>>>> >Saxonica
>>>>>>>> >
>>>>>>>> >> On 13 Aug 2020, at 13:52, Ihe Onwuka <[email protected]>
>>>>>>>> wrote:
>>>>>>>> >>
>>>>>>>> >> This is not my code.
>>>>>>>> >>
>>>>>>>> >> Warning at char 1 in xsl:template/@match on line 62 column 72 of
>>>>>>>> >******.xsl:
>>>>>>>> >>   XPTY0004  An error occurred matching pattern
>>>>>>>> >>
>>>>>>>> >{element()[Q{
>>>>>>>> http://www.w3.org/2005/xpath-functions/map}contains($actions
>>>>>>>> ><http://www.w3.org/2005/xpath-functions/map%7Dcontains($actions>,
>>>>>>>> >>   exactly-one(first(tokenize(convertUntyped(data(.)), "\s",
>>>>>>>> ""))))]}:
>>>>>>>> >>
>>>>>>>> >> My code was
>>>>>>>> >>
>>>>>>>> >>
>>>>>>>> >>    <xsl:template
>>>>>>>> >match="*[map:contains($actions,tokenize(.,'\s')[1])]">
>>>>>>>> >> _______________________________________________
>>>>>>>> >> saxon-help mailing list archived at http://saxon.markmail.org/
>>>>>>>> >> [email protected]
>>>>>>>> >> https://lists.sourceforge.net/lists/listinfo/saxon-help
>>>>>>>> >
>>>>>>>> >_______________________________________________
>>>>>>>> >saxon-help mailing list archived at http://saxon.markmail.org/
>>>>>>>> >[email protected]
>>>>>>>> >https://lists.sourceforge.net/lists/listinfo/saxon-help
>>>>>>>>
>>>>>>>> --  Sent from my p≡p for
>>>>>>>> Android._______________________________________________
>>>>>>>> saxon-help mailing list archived at http://saxon.markmail.org/
>>>>>>>> [email protected]
>>>>>>>> https://lists.sourceforge.net/lists/listinfo/saxon-help
>>>>>>>
>>>>>>> _______________________________________________
>>>>>>> saxon-help mailing list archived at http://saxon.markmail.org/
>>>>>>> [email protected]
>>>>>>> https://lists.sourceforge.net/lists/listinfo/saxon-help
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>
>>>
>>> _______________________________________________
>>> saxon-help mailing list archived at http://saxon.markmail.org/[email protected]://lists.sourceforge.net/lists/listinfo/saxon-help
>>>
>>> _______________________________________________
>>> saxon-help mailing list archived at http://saxon.markmail.org/
>>> [email protected]
>>> https://lists.sourceforge.net/lists/listinfo/saxon-help
>>
>>

_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[email protected]
https://lists.sourceforge.net/lists/listinfo/saxon-help
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.