You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tuscany.apache.org by "Yang ZHONG (JIRA)" <tu...@ws.apache.org> on 2006/06/29 00:56:32 UTC

[jira] Commented: (TUSCANY-505) xsi:type on root element fo XML doc causes problems

    [ http://issues.apache.org/jira/browse/TUSCANY-505?page=comments#action_12418335 ] 

Yang ZHONG commented on TUSCANY-505:
------------------------------------

First of all, there're spaces within NameSpace in both XSD and XML, it makes references broken, especially
    <schema xmlns=" http://www.w3.org/2001/XMLSchema"
makes SDO implementation NOT recognizing XSD at all.
My previous commercial product experience has taught me that utilizing XSD and XML validator may save issue opener many time.

I've tried to reproduce, without calling XSDHelper#define, I get
    org.apache.tuscany.sdo.impl.AnyTypeDataObjectImpl
from the XML without xsi:type, and NO root from the XML with xsi:type.
That seems the same result Simon is seeing.

I've also tried XMLHelper#load(inputStream,LOCATION,options) and hope the loader can pick up the XSD since the XMLs have specified schemaLocation as
    xsi:schemaLocation="http://www.apache.org/tuscany/interop interop01.xsd">
Unfortunately, XMLHelper seems ignoring the specified schema.

Calling XSDHelper#define (and having corrected the XSD and XML), then I get things working:

public final class XsiType extends junit.framework.TestCase
{
  public void test () throws java.io.IOException
  {
    final ClassLoader classes = XsiType.class.getClassLoader();
    java.net.URL url = classes.getResource( "interop01.xsd");
    XSDHelper.INSTANCE.define( url.openStream(), url.toString());
      //  IOException may be thrown
//    assertNotNull( XSDHelper.INSTANCE.getGlobalProperty( "http://www.apache.org/tuscany/interop", "RootElement", true));
//    assertNotNull( TypeHelper.INSTANCE.getType( "http://www.apache.org/tuscany/interop", "ComplexTypeRootType"));
    url = classes.getResource( "typeXSI.XML");
    final Object  root = XMLHelper.INSTANCE.load
      //  IOException may be thrown
    ( 
      url.openStream()  
        //  IOException may be thrown
    ).getRootObject();
    assertNotNull( root);
  }
}

So, I think it's a usage error.
On the other hand, not sure if XMLHelper needs to honor schemaLocation. If yes, current XMLHelper#load may have a defect.

> xsi:type on root element fo XML doc causes problems
> ---------------------------------------------------
>
>          Key: TUSCANY-505
>          URL: http://issues.apache.org/jira/browse/TUSCANY-505
>      Project: Tuscany
>         Type: Bug

>   Components: Java SDO Implementation
>     Versions: Java-M1
>  Environment: Windows XP
>     Reporter: Simon Laws

>
> If I read the following doc:
> <tns:RootElement xmlns:p="commonj.sdo"
>     xmlns:tns="http://www.apache.org/tuscany/interop"
>     xmlns:xsi=" http://www.w3.org/2001/XMLSchema-instance"
>     xsi:schemaLocation="http://www.apache.org/tuscany/interop interop01.xsd">
>     <SimpleTypeWithName>SimpleTypeWithName</SimpleTypeWithName>
> </tns:RootElement>
> With the following schema
> <schema xmlns=" http://www.w3.org/2001/XMLSchema"
>         targetNamespace="http://www.apache.org/tuscany/interop"
>         xmlns:tns=" http://www.apache.org/tuscany/interop">
>  
>   <include schemaLocation="interop10.xsd"/>
>      
>   <!-- top level test type -->      
>   <complexType name="ComplexTypeRootType">
>     <sequence>
>       <!-- simple types -->
>       <element name="SimpleTypeWithName" type="tns:SimpleTypeWithNameType"/>
>     </sequence>
>   </complexType>
>        
>   <element name="RootElement" type="tns:ComplexTypeRootType"/>
> </schema>
> The I get a valid document (doc) with some data objects in it out of the following code:
>         FileInputStream inFileStream = new FileInputStream (inFileName);
>         XMLDocument doc = XMLHelper.INSTANCE.load(inFileStream);
> If I try in read in (note I have added and xsi:type attribute):
> <tns:RootElement xmlns:p="commonj.sdo"
>     xsi:type="tns:ComplexTypeRootType"
>     xmlns:tns="http://www.apache.org/tuscany/interop "
>     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>     xsi:schemaLocation="http://www.apache.org/tuscany/interop interop01.xsd">
>     <SimpleTypeWithName>SimpleTypeWithName</SimpleTypeWithName>
> </tns:RootElement>
> The XMLHelper silently makes an empty document, i.e. the root element is null.
> I talked with Frank and he suggested changing the xsi:type to refer to a type that extends the root element type. This produced the same effect, i.e. and empty document. However xsi:type does seem to behave in both the base type and extension type case when attached to elements other than the root element. 

-- 
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: tuscany-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-dev-help@ws.apache.org