Re: Pattern matching error in xsl:key

Ihe Onwuka <[email protected]>
Newsgroups gmane.text.xml.saxon.help
Message-ID <CALfs7+ygd__OHeBd5d_9HyDDUky40dA2bS9M4KUqWdJ97PrFvA@mail.gmail.com>
On Sat, Sep 5, 2020 at 9:26 AM Michael Kay <mike-JkSD5nQpfvpWk0Htik3J/[email protected]> wrote:

> It's unfortunate that the message doesn't actually say what the error was.
> That's a bug.
>
> Also unfortunate, you haven't supplied enough information for me to
> reproduce the problem, so I can't tell you any more about it. The
> information you've supplied is incomplete, and it's also incorrect
> (misspelt end tag in the XML).
>

No doubt in excerpting I omitted some relevant info. I'll try and fix that.
The XML content is in a separate document and globally namespaced.
Here.

<versionChanges xmlns="http://changes" >
  <changes from="4.0" to="4.1">
     <rename>
        <metadata/>
     </rename>
  </changes>
</versionChanges>

and here is the error message

Warning at char 11 in xsl:key/@match on line 36 column 111 of
myStylesheet.xsl:
  XPTY0004  An error occurred matching pattern
  {element(Q{http://changes}changes)[((data(attribute::attribute(Q{}from)))
eq
  (atomizeSingleton($source))) and ((data(attribute::attribute(Q{}to))) eq
  (atomizeSingleton($target)))]}:



> My guess would be that it's a type error connected with the fact you're
> comparing numbers to strings, but beyond that,
>

I am comparing parameters whose values are 4.0 and 4.1 respectively to
attributes whose values are 4.0 and 4.1 respectively. Saxon has made it's
own assumptions about what types they are and come up with that error.


> I can't say. As Martin says, declaring types using an "as" attribute on
> xsl:param is basic hygiene; it may not prevent type errors, but it will
> always result in better diagnostics.
>
>
No it doesn't.

Error at xsl:param on line 8 column 58 of myStylesheet.xsl:
  XTTE0590  The required item type of the value of parameter $source is
xs:string. The
  supplied value is of type xs:decimal
Errors were reported during stylesheet compilation



> Michael Kay
> Saxonica
>
> On 5 Sep 2020, at 10:43, Ihe Onwuka <[email protected]> wrote:
>
> <versionChanges  >
>   <changes from="4.0" to="4.1">
>       <rename from="me" to="you"/>
>   </changes>
> </versionChages>
>
>    <xsl:param name="source" select="4.0"/>
>    <xsl:param name="target" select="4.1"/>
>
>    <xsl:key name="changes" match="changes[@from eq $source and @to eq
> $target]/rename/*" use="@from"/>
>
> Warning at char 11 in xsl:key/@match on line 36 column 111 of
> translator.xsl:
>   XPTY0004  An error occurred matching pattern
>   {element(Q{mynamespace}changes)[((data(attribute::attribute(Q{}from))) eq
>   (atomizeSingleton($source))) and ((data(attribute::attribute(Q{}to))) eq
>   (atomizeSingleton($target)))]}:
>
>
> _______________________________________________
> 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.