[ 
http://issues.apache.org/jira/browse/TUSCANY-696?page=comments#action_12432980 
] 
            
Robbie Minshall commented on TUSCANY-696:
-----------------------------------------

I just wrote a quick junit test that essentially does what you do with the 
company xsd and xml files as well as with the ones you originally used.  

public void testXMLStreamHelper(String xsd, String xml) {
                try {

                        URL testxmlURLx = getClass().getResource(xml);
                        XMLStreamReader streamReaderx = 
XMLInputFactory.newInstance()
                                        
.createXMLStreamReader(testxmlURLx.openStream());

                        xmlStreamReader2XmlText(streamReaderx, System.out);
                        System.out.println();
                        System.out.println("=========");

                        System.out
                                        .println("Now run the same file with 
SDO to StaX adapter (XMLStreamHelper): ");

                        XMLHelper xmlHelper = XMLHelper.INSTANCE;
                        XSDHelper xsdHelper = XSDHelper.INSTANCE;
                        TypeHelper typeHelper = TypeHelper.INSTANCE;

                        // define types
                        List xsdTypes = xsdHelper.define(getClass()
                                        .getResourceAsStream(xsd), null);

                        // obtain dataobject
                        DataObject rootobj = XMLHelper.INSTANCE.load(
                                        
getClass().getResourceAsStream(xml)).getRootObject();

                        System.out.println("Type of rootObject " + 
rootobj.getType().getName() );
                        
                        // obtain an xml stream helper
                        XMLStreamHelper xmlStreamHelper = SDOUtil
                                        .createXMLStreamHelper(typeHelper);

                        XMLStreamReader streamReader = xmlStreamHelper
                                        .createXMLStreamReader(rootobj);

                        xmlStreamReader2XmlText(streamReader, System.out);
                        System.out.println();
                        
                } catch (Exception e) {
                        System.out.println("Exception : " + e.toString());
                        e.printStackTrace();
                        fail(e.toString());
                }
        }

With the company xsd/xml file it ran without errors though I am  unsure of the 
quality of the output ( do you know where is the p0:  is from ) 
<p0:CompanyType employeeOfTheMonth="E0001" name="ACME"><departments 
number="123" location="NY" name="Advanced Technologies" xmlns=""><employees 
SN="E0001" name="John Jones" /><employees SN="E0003" name="Jane Doe" 
/><employees manager="true" SN="E0004" name="A Varone" /></departments>

With the XMLDocumentNoNamespaceSchemaLocation.xsd and XMLDocumentTestCase.xml I 
got a java.lang.NullPointerException calling xsr.getEventType() in the switch 
statement.    The rootObject is getting returned as AnyTypeDataObject.

I hate xml so will need to read study the NoNameSpace xsd some more ( might get 
to it tomorrow afternoon some time )  . . . are you wanting to pursue using 
this xsd and xml or make some progress using another schema and data ?

Robbie





> XMLStreamHelper usage
> ---------------------
>
>                 Key: TUSCANY-696
>                 URL: http://issues.apache.org/jira/browse/TUSCANY-696
>             Project: Tuscany
>          Issue Type: Bug
>          Components: Java SDO Implementation
>         Environment: Windows XP, java version "1.5.0_07" Java(TM) 2 Runtime 
> Environment, Standard Edition (build 1.5.0_07-b03)
> Java HotSpot(TM) Client VM (build 1.5.0_07-b03, mixed mode, sharing)
>            Reporter: Scott Boag
>         Attachments: SimpleRun2.java, 
> XMLDocumentNoNamespaceSchemaLocation.xsd, XMLDocumentTestCase.xml
>
>
> Not sure if this is a bug or user problem or both.  I am trying to work on a 
> generic lossless adapter from SDO to a XML data model, without intervening 
> serialization.
> I'm running the following code:
>               XMLHelper xmlHelper = XMLHelper.INSTANCE;
>               XSDHelper xsdHelper = XSDHelper.INSTANCE;
>               TypeHelper typeHelper = TypeHelper.INSTANCE;
>               URL url = SimpleRun2.class.getClassLoader().getResource(
>                               NNS_SCHEMA_LOCATION);
>               List xsdTypes = xsdHelper
>                               .define(url.openStream(), url.toExternalForm());
>               // InputStream is = new FileInputStream(TEST_XML_DOCUMENT);
>               URL testxmlURL = SimpleRun2.class.getClassLoader().getResource(
>                               TEST_XML_DOCUMENT);
>               XMLDocument doc = xmlHelper.load(testxmlURL.openStream());
>               DataObject rootobj = doc.getRootObject();
>               // typeHelper.define(xsdTypes);
>               XMLStreamHelper xmlStreamHelper = SDOUtil
>                               .createXMLStreamHelper(typeHelper);
>               XMLStreamReader streamReader = xmlStreamHelper
>                               .createXMLStreamReader(rootobj);
>               xmlStreamReader2XmlText(streamReader, System.out);
> (xmlStreamReader2XmlText is just a utility method I lifted from somewhere)
> Raymond told me in a private exchange that I needed to do 
> "TypeHelper.INSTANCE.define(InputStream xsd, String schemaLocation); " 
> (though that implies that I know ahead of time the schema). Since TypeHelper 
> doesn't have a define that takes the schema, I assume the above is what he 
> meant.  If I pass the result of the xsdHelper.define to typeHelper.define, it 
> crashes in spectacular ways.
> When I run this code, the result is:
> <p0:AnyTypeDataObject>
> Which is clearly wrong.  I've included the complete program.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to