[ 
http://issues.apache.org/jira/browse/TUSCANY-696?page=comments#action_12433383 
] 
            
Fuhwei Lwo commented on TUSCANY-696:
------------------------------------

Based on current Tuscany SDO design and implementation, one should define types 
before loading their instances in XML document for example. Otherwise, 
AnyTypeDataObject will be returned.

The solution for this JIRA is to add the following 2 lines before loading the 
document -

url = 
SimpleRun2.class.getClassLoader().getResource("XMLDocumentSchemaLocation.xsd");
xsdHelper.define(url.openStream(), url.toExternalForm());

To support discovering the types when loading the instance document is a new 
SDO feature.  I have opened TUSCANY-713 as a feature to track this requirement.

> 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: robbieResults_1.txt, 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