ulsdevteam / ojs-sushiLite-plugin

SUSHI-Lite plugin for OJS
GNU General Public License v2.0
2 stars 3 forks source link

XML conversion to JSON mishandles singletons #2

Closed ctgraham closed 8 years ago

ctgraham commented 8 years ago

The XML:

<?xml version="1.0"?>
<sc:ReportResponse xmlns:sc="http://www.niso.org/schemas/sushi/counter" xmlns:s="http://www.niso.org/schemas/sushi" xmlns:c="http://www.niso.org/schemas/counter" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.niso.org/schemas/sushi http://www.niso.org/schemas/sushi/sushi1_7.xsd http://www.niso.org/schemas/sushi/counter http://www.niso.org/schemas/sushi/sushi_counter4_1.xsd ">
  <s:Requestor>
    <s:ID>anonymous</s:ID>
    <s:Name/>
    <s:Email/>
  </s:Requestor>
  <s:CustomerReference>
    <s:ID/>
  </s:CustomerReference>
</sc:ReportResponse>

is being converted to:

{"sc:ReportResponse":{
  "@xsi:schemaLocation":"http://www.niso.org/schemas/sushi http://www.niso.org/schemas/sushi/sushi1_7.xsd http://www.niso.org/schemas/sushi/counter http://www.niso.org/schemas/sushi/sushi_counter4_1.xsd ",
  "s:Requestor":{
    "s:ID":"anonymous",
    "Name":null,
    "Email":null,
    "s:CustomerReference":"ID":null
  }
}

There are two problems:

  1. The empty elements are losing their namespace. Cause: https://github.com/ulsdevteam/ojs-sushiLite-plugin/blob/d70a81f80d74780b35c69b5d2a8fa493c8442317/xml2json.xslt#L144
  2. The second element is being enveloped by the first, with no formatting of the singleton contained. Cause: ???
ctgraham commented 8 years ago

Fix merged to master.