Uploaded image for project: 'Tuscany'
  1. Tuscany
  2. TUSCANY-2571

xs:Date output not compliant with spec

    XMLWordPrintableJSON

Details

    Description

      Hello,

      I have found some deviation from the XML spec. when I use XMLHelper.INSTANCE.save.
      The problem occurs when I want to print Date (xs:Date).
      It looks e.g.: 2008-07-11 UTC
      Instead of: 2008-07-11Z.

      Can anybody confirm if this is a bug?

      I debugged the source code and found a pattern at line 453:
      SDOSimpleDateFormat f = new SDOSimpleDateFormat("yyyy-MM-dd zz");
      in the method:
      public synchronized String toYearMonthDay(Date date)

      I also found similar patterns in other methods too.

      I have created a small demo for representing my problem.

      The code:
      --------------
      public class DemoSdo {

      public static void main(String[] args) throws IOException

      { HelperContext ctx = HelperProvider.getDefaultContext(); FileInputStream is = new FileInputStream("src/sdo/DemoSDO.xsd"); XSDHelper xsdHelper = ctx.getXSDHelper(); xsdHelper.define(is, null); DataFactory f = ctx.getDataFactory(); DataObject newDO = f.create("http://DemoSDO/src/sdo", "DemoSDO"); Date d = new Date(); newDO.setDate("timeStamp", d); newDO.setDate("demoDate", d); String uri = newDO.getType().getURI(); String name = newDO.getType().getName(); String serializedDO = XMLHelper.INSTANCE.save(newDO, uri, name); System.out.println(serializedDO); }

      }

      The XML schema:
      --------------------------
      <?xml version="1.0" encoding="UTF-8"?>
      <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
      targetNamespace="http://DemoSDO/src/sdo">
      <xsd:complexType name="DemoSDO">
      <xsd:sequence>
      <xsd:element name="timeStamp" type="xsd:dateTime">
      </xsd:element>
      <xsd:element name="demoDate" type="xsd:date">
      </xsd:element>
      </xsd:sequence>
      </xsd:complexType>
      </xsd:schema>

      The output:
      ----------------
      <?xml version="1.0" encoding="UTF-8"?>
      <sdo:DemoSDO xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:sdo="http://DemoSDO/src/sdo" xsi:type="sdo:DemoSDO">
      <timeStamp>2008-08-28T10:10:40.366Z</timeStamp>
      <demoDate>2008-08-28 UTC</demoDate>
      </sdo:DemoSDO>

      According to the specification demoDate should be 2008-08-28Z.

      Attachments

        Activity

          People

            Unassigned Unassigned
            czollli Zoltan Borsos
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: