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

Exception in thread "main" java.lang.IllegalArgumentException: Cannot generate XSD since SDO Type 'item' was orginally generated from XSD. Use original XSD

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Blocker
    • Resolution: Invalid
    • Java-SDO-beta1
    • Java-SDO-1.0
    • None

    Description

      package com.hollycrm.sdo;

      import java.io.FileWriter;
      import java.io.Writer;
      import java.util.Iterator;
      import java.util.List;

      import org.apache.tuscany.samples.sdo.SdoSampleConstants;
      import org.apache.tuscany.sdo.util.SDOUtil;

      import commonj.sdo.Type;
      import commonj.sdo.helper.HelperContext;
      import commonj.sdo.helper.TypeHelper;
      import commonj.sdo.helper.XMLHelper;
      import commonj.sdo.helper.XSDHelper;

      public class POXSDTest {
      public static void main(String[]argv)throws Exception

      { HelperContext hc = SDOUtil.createHelperContext(true); hc.getXSDHelper().define(ClassLoader.getSystemResourceAsStream("po.xsd"), null); List allTypes = SDOUtil.getTypes(hc.getTypeHelper(), "http://www.example.com/PO"); removeDocumentRootType(allTypes); String xsd = hc.getXSDHelper().generate(allTypes); Writer w = new FileWriter("po2.xsd"); w.write(xsd); }

      /**

      • eliminate a bug
      • @param allTypes
        */
        private static void removeDocumentRootType(List allTypes) {
        for (Iterator iter = allTypes.iterator(); iter.hasNext() {
        Type t = (Type) iter.next();
        if ("DocumentRoot".equals(t.getName())) { iter.remove(); continue; }

      }
      }
      }
      ---------------------------console out----------------------------------
      Exception in thread "main" java.lang.IllegalArgumentException: Cannot generate XSD since SDO Type 'item' was orginally generated from XSD. Use original XSD
      at org.apache.tuscany.sdo.helper.XSDHelperImpl.generate(XSDHelperImpl.java:291)
      at org.apache.tuscany.sdo.helper.XSDHelperImpl.generate(XSDHelperImpl.java:235)
      at com.hollycrm.sdo.POXSDTest.main(POXSDTest.java:24)

      Attachments

        Activity

          People

            Unassigned Unassigned
            lazet lizhantao
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: