[Bug 28662] New: Editorial: Example for fn:json-to-xml

https://www.w3.org/Bugs/Public/show_bug.cgi?id=28662

            Bug ID: 28662
           Summary: Editorial: Example for fn:json-to-xml
           Product: XPath / XQuery / XSLT
           Version: Candidate Recommendation
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: minor
          Priority: P2
         Component: Functions and Operators 3.1
          Assignee: mike@saxonica.com
          Reporter: christian.gruen@gmail.com
        QA Contact: public-qt-comments@w3.org

In the "Examples" section of fn:json-to-xml, it's a bit surprising to have code
in the XSLT syntax. Maybe it could be replaced with the following equivalent
example:

  let $jsonstr := unparsed-text('http://example.com/endpoint')
  let $options := map {
    'liberal': true(),
    'fallback': function($char as xs:string) as xs:string {
      let $c0chars := map {
        '\u0000':'[NUL]',
        '\u0001':'[SOH]',
        '\u0002':'[STX]',
        ...
        '\u001E':'[RS]',
        '\u001F':'[US]'
      }
      let $replacement := $c0chars($char)
      return if (exists($replacement))
        then $replacement
        else error(xs:QName('err:invalid-char'), 
          'Error: ' || $char || ' is not a terminal control char.')
    }
  }
  return json-to-xml($jsonstr, $options)

-- 
You are receiving this mail because:
You are the QA Contact for the bug.

Received on Wednesday, 20 May 2015 14:47:39 UTC