One of the map element causes SEPM0017 error

Friday, 3 April 2020 · 3 messages · last reply 6 Apr 2020
AB
Arkadiusz Bok3 Apr 2020 18:51 #
Hi, I'm trying to run one of unchanged code example from book "XQuery: Search Across a Variety of XML Data 2nd Edition" from publisher O'Reilly Media. |(: XQuery by Priscilla Walmsley (c) 2016 Priscilla Walmsley:) |
|(:Example 13-4 Serialization parameters in a map :) xquery version
"3.1"; declare namespace prod = "http://datypic.com/prod"; let $map :=
map { "method": "xml", "version": "1.0", "indent": true(),
"cdata-section-elements": (xs:QName("prod:desc"),xs:QName("prod:name")),
"use-character-maps": map { "«":"<%", "»":">%" } } let $element :=
<prod:name>Fleece Pullover</prod:name> return serialize($element,$map) |
I'm using BaseX 9.3.2 to do this. But when I'm trying to run code, I get error: |Stopped at C:/Users/Arek/AppData/Local/Temp/example1304.xqy, 16/17: [SEPM0017] item() expected, xs:QName+ found: (Q{http://datypic.com/prod}desc, Q{http://datypic.com/prod}name). | When i remove 9 line with /cdata-section-elements/ element, code runs. Whether is it problem with XQuery implementation or with code? ||||
CG
Christian Grün6 Apr 2020 09:07 #
Hi Arkadius, In BaseX, the serialization parameters were added to fn:serialize before the feature was added to the official spec, that’s why the implementation still differs a little. You’ll need to supply the CDATA section element names in a single string:
  let $map := map {
    "cdata-section-elements": "a xml c"
  }
  let $element := <xml>Hello</xml>
  return serialize($element,$map)
If the element name has a namespace, the EQName notation will do the job:
  declare namespace prod = "http://datypic.com/prod";
  let $map := map { "cdata-section-elements":
    "Q{http://datypic.com/prod}desc Q{http://datypic.com/prod}name"
  }
  let $element := <prod:name>Fleece Pullover</prod:name>
  return serialize($element,$map)
We’ll align the behavior in a future version of BaseX. Hope this helps, Christian
Quoted text · Arkadiusz Bok · 29 lines
On Fri, Apr 3, 2020 at 6:51 PM Arkadiusz Bok <arkadiusz_bok at o2.pl> wrote: > > Hi, > I'm trying to run one of unchanged code example from book "XQuery: Search Across a Variety of XML Data 2nd Edition" from publisher O'Reilly Media. > > (: XQuery by Priscilla Walmsley (c) 2016 Priscilla Walmsley:) > > (:Example 13-4 Serialization parameters in a map :) > xquery version "3.1"; > declare namespace prod = "http://datypic.com/prod"; > let $map := map { > "method": "xml", > "version": "1.0", > "indent": true(), > "cdata-section-elements": (xs:QName("prod:desc"),xs:QName("prod:name")), > "use-character-maps": map { > "«":"&lt;%", > "»":"&gt;%" > } > } > let $element := <prod:name>Fleece Pullover</prod:name> > return serialize($element,$map) > > I'm using BaseX 9.3.2 to do this. But when I'm trying to run code, I get error: > > Stopped at C:/Users/Arek/AppData/Local/Temp/example1304.xqy, 16/17: > [SEPM0017] item() expected, xs:QName+ found: (Q{http://datypic.com/prod}desc, Q{http://datypic.com/prod}name). > > When i remove 9 line with cdata-section-elements element, code runs. Whether is it problem with XQuery implementation or with code?
CG
Christian Grünin reply to Arkadiusz Bok, 3 Apr 2020, 18:516 Apr 2020 13:53 #
Dear Arkadiusz, I have improved argument parsing for the fn:serialize function. Your code snippet from Priscilla’s great reference book will be successfully evaluated with the latest stable snapshot of BaseX [1]. Dziękuję & cześć, Christian [1] http://files.basex.org/releases/latest/
Quoted text · Arkadiusz Bok · 29 lines
On Fri, Apr 3, 2020 at 6:51 PM Arkadiusz Bok <arkadiusz_bok at o2.pl> wrote: > > Hi, > I'm trying to run one of unchanged code example from book "XQuery: Search Across a Variety of XML Data 2nd Edition" from publisher O'Reilly Media. > > (: XQuery by Priscilla Walmsley (c) 2016 Priscilla Walmsley:) > > (:Example 13-4 Serialization parameters in a map :) > xquery version "3.1"; > declare namespace prod = "http://datypic.com/prod"; > let $map := map { > "method": "xml", > "version": "1.0", > "indent": true(), > "cdata-section-elements": (xs:QName("prod:desc"),xs:QName("prod:name")), > "use-character-maps": map { > "«":"&lt;%", > "»":"&gt;%" > } > } > let $element := <prod:name>Fleece Pullover</prod:name> > return serialize($element,$map) > > I'm using BaseX 9.3.2 to do this. But when I'm trying to run code, I get error: > > Stopped at C:/Users/Arek/AppData/Local/Temp/example1304.xqy, 16/17: > [SEPM0017] item() expected, xs:QName+ found: (Q{http://datypic.com/prod}desc, Q{http://datypic.com/prod}name). > > When i remove 9 line with cdata-section-elements element, code runs. Whether is it problem with XQuery implementation or with code?

⚡Generated with XQuery