You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@tuscany.apache.org by Thomas Trenz <th...@blue-elephant-systems.com> on 2009/07/27 12:15:13 UTC

Problems with XSDHelper.define and schema file having import statements...

Hello,

I am using Apache Tuscany SDO 1.1.1 and I have a problem loading a 
schema file with an import statement. What happens is that I can create 
data objects of types that are included in the main file. However, when 
I try to create objects from the imported file, I get the following error:

java.lang.IllegalArgumentException in 
org.apache.tuscany.sdo.util.DataObjectUtil.create(DataObjectUtil.java:2549).

The code to load the schema file is:

  public static void initHelperContext () throws FileNotFoundException
  {
    hc = SDOUtil.createHelperContext();

    XSDHelper xsdHelper = hc.getXSDHelper();
   
    File f2 = new File ("c:\temp\schema.xsd");
    InputStream is2 = new FileInputStream (f2);
    xsdHelper.define(is2, f2.getAbsolutePath());
  }

That's how the schema file gets imported:

  <xsd:import namespace="<our namespace>" schemaLocation="include.xsd"/>

When I copy the definitions from the imported file into the main file, 
then everything works fine...

Any help is appreciated...

Thanks
Thomas

Re: Problems with XSDHelper.define and schema file having import statements...

Posted by Thomas Trenz <th...@blue-elephant-systems.com>.
Frank Budinsky schrieb:
>
> Hi Thomas,
>
> Since you don't show what schema.xsd and include.xsd contain, and what 
> type you're trying to create when you get the error, it's very hard to 
> guess what the problem might be.
>
> Things to check:
>
> 1) Is include.xsd in the same folder as schema.xsd (i.e., c:\temp)? It 
> should be.
> 2) What is the targetNamespace of the schema in schema.xsd? Is it 
> different from the namespace you're importing ("<our namespace>")? It 
> should be different.
> 3) What is the target namespace of the schema in include.xsd? Is it 
> the same as namespace you're importing ("<our namespace>")? It should 
> be the same.
> 4) Are you creating the type from the included schema using the 
> imported namespace ("<our namespace>") as the URI argument ? You 
> should be.
>
> Frank.
>
> Thomas Trenz <th...@blue-elephant-systems.com> wrote on 
> 07/27/2009 06:15:13 AM:
>
> > Hello,
> >
> > I am using Apache Tuscany SDO 1.1.1 and I have a problem loading a
> > schema file with an import statement. What happens is that I can create
> > data objects of types that are included in the main file. However, when
> > I try to create objects from the imported file, I get the following 
> error:
> >
> > java.lang.IllegalArgumentException in
> > 
> org.apache.tuscany.sdo.util.DataObjectUtil.create(DataObjectUtil.java:2549).
> >
> > The code to load the schema file is:
> >
> >   public static void initHelperContext () throws FileNotFoundException
> >   {
> >     hc = SDOUtil.createHelperContext();
> >
> >     XSDHelper xsdHelper = hc.getXSDHelper();
> >    
> >     File f2 = new File ("c:\temp\schema.xsd");
> >     InputStream is2 = new FileInputStream (f2);
> >     xsdHelper.define(is2, f2.getAbsolutePath());
> >   }
> >
> > That's how the schema file gets imported:
> >
> >   <xsd:import namespace="<our namespace>" schemaLocation="include.xsd"/>
> >
> > When I copy the definitions from the imported file into the main file,
> > then everything works fine...
> >
> > Any help is appreciated...
> >
> > Thanks
> > Thomas
>
Hi Frank,

thanks a lot for your quick reply. In our case, both .xsd files have the 
same namespace. So we're violating your second point. Is there any 
reason, why that is not allowed?

Best regards,
Thomas

-- 
-------------------------------------------------------------------
Thomas Trenz
blue elephant systems GmbH
Wollgrasweg 49
70599 Stuttgart
Germany

Tel.: +49 711 451 017 - 579
Fax.: +49 711 451 017 - 573
Email: thomas.trenz@blue-elephant-systems.com

Sitz: Stuttgart, Amtsgericht Stuttgart, HRB 24106
Geschäftsführer:  Joachim Hörnle, Thomas Gentsch, Holger Dietrich


Re: Problems with XSDHelper.define and schema file having import statements...

Posted by Thomas Trenz <th...@blue-elephant-systems.com>.
Frank Budinsky schrieb:
>
> Hi Thomas,
>
> I just noticed one more thing in your note. Are you confusing import 
> with include? If you just want to tinclude types in the same 
> namespace, you should be using an include statement like this:
>
> <xsd:include schemaLocation="include.xsd"/>
>
> instead of the import statement you show below:
>
> <xsd:import namespace="<our namespace>" schemaLocation="include.xsd"/>
>
> Frank.
>
> Frank Budinsky/Toronto/IBM@IBMCA wrote on 07/27/2009 09:36:37 AM:
>
> > Hi Thomas,
> >
> > Since you don't show what schema.xsd and include.xsd contain, and
> > what type you're trying to create when you get the error, it's very
> > hard to guess what the problem might be.
> >
> > Things to check:
> >
> > 1) Is include.xsd in the same folder as schema.xsd (i.e., c:\temp)?
> > It should be.
> > 2) What is the targetNamespace of the schema in schema.xsd? Is it
> > different from the namespace you're importing ("<our namespace>")?
> > It should be different.
> > 3) What is the target namespace of the schema in include.xsd? Is it
> > the same as namespace you're importing ("<our namespace>")? It
> > should be the same.
> > 4) Are you creating the type from the included schema using the
> > imported namespace ("<our namespace>") as the URI argument ? You 
> should be.
> >
> > Frank.
> >
> > Thomas Trenz <th...@blue-elephant-systems.com> wrote on
> > 07/27/2009 06:15:13 AM:
> >
> > > Hello,
> > >
> > > I am using Apache Tuscany SDO 1.1.1 and I have a problem loading a
> > > schema file with an import statement. What happens is that I can 
> create
> > > data objects of types that are included in the main file. However, 
> when
> > > I try to create objects from the imported file, I get the 
> following error:
> > >
> > > java.lang.IllegalArgumentException in
> > > 
> org.apache.tuscany.sdo.util.DataObjectUtil.create(DataObjectUtil.java:2549).
> > >
> > > The code to load the schema file is:
> > >
> > >   public static void initHelperContext () throws FileNotFoundException
> > >   {
> > >     hc = SDOUtil.createHelperContext();
> > >
> > >     XSDHelper xsdHelper = hc.getXSDHelper();
> > >    
> > >     File f2 = new File ("c:\temp\schema.xsd");
> > >     InputStream is2 = new FileInputStream (f2);
> > >     xsdHelper.define(is2, f2.getAbsolutePath());
> > >   }
> > >
> > > That's how the schema file gets imported:
> > >
> > >   <xsd:import namespace="<our namespace>" 
> schemaLocation="include.xsd"/>
> > >
> > > When I copy the definitions from the imported file into the main 
> file,
> > > then everything works fine...
> > >
> > > Any help is appreciated...
> > >
> > > Thanks
> > > Thomas
>
Hi Frank,

I also tried xsd:include. Same result. I cannot create objects from the 
included file.

Here is the beginning of our schema.xsd file (with the include version 
that I tried with the same result as import):

<?xml version="1.0"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
            xmlns:ovo="http://blue-elephant-systems.com/midas/ovo/1.0"
            xmlns:do="http://www.openadaptor.org"
            elementFormDefault="qualified"
            
targetNamespace="http://blue-elephant-systems.com/midas/ovo/1.0">

  <xsd:include schemaLocation="ovocommon.xsd"/>
....

And here is the beginning of our included file "ovocommon.xsd":

<?xml version="1.0"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
            xmlns:ovo="http://blue-elephant-systems.com/midas/ovo/1.0"
            xmlns:do="http://www.openadaptor.org"
            elementFormDefault="qualified"
            
targetNamespace="http://blue-elephant-systems.com/midas/ovo/1.0">
....

Best regards,
Thomas

-- 
-------------------------------------------------------------------
Thomas Trenz
blue elephant systems GmbH
Wollgrasweg 49
70599 Stuttgart
Germany

Tel.: +49 711 451 017 - 579
Fax.: +49 711 451 017 - 573
Email: thomas.trenz@blue-elephant-systems.com

Sitz: Stuttgart, Amtsgericht Stuttgart, HRB 24106
Geschäftsführer:  Joachim Hörnle, Thomas Gentsch, Holger Dietrich


Re: Problems with XSDHelper.define and schema file having import statements...

Posted by Frank Budinsky <fr...@ca.ibm.com>.
Hi Thomas,

I just noticed one more thing in your note. Are you confusing import with
include? If you just want to tinclude types in the same namespace, you
should be using an include statement like this:

<xsd:include schemaLocation="include.xsd"/>

instead of the import statement you show below:

<xsd:import namespace="<our namespace>" schemaLocation="include.xsd"/>

Frank.

Frank Budinsky/Toronto/IBM@IBMCA wrote on 07/27/2009 09:36:37 AM:

> Hi Thomas,
>
> Since you don't show what schema.xsd and include.xsd contain, and
> what type you're trying to create when you get the error, it's very
> hard to guess what the problem might be.
>
> Things to check:
>
> 1) Is include.xsd in the same folder as schema.xsd (i.e., c:\temp)?
> It should be.
> 2) What is the targetNamespace of the schema in schema.xsd? Is it
> different from the namespace you're importing ("<our namespace>")?
> It should be different.
> 3) What is the target namespace of the schema in include.xsd? Is it
> the same as namespace you're importing ("<our namespace>")? It
> should be the same.
> 4) Are you creating the type from the included schema using the
> imported namespace ("<our namespace>") as the URI argument ? You should
be.
>
> Frank.
>
> Thomas Trenz <th...@blue-elephant-systems.com> wrote on
> 07/27/2009 06:15:13 AM:
>
> > Hello,
> >
> > I am using Apache Tuscany SDO 1.1.1 and I have a problem loading a
> > schema file with an import statement. What happens is that I can create

> > data objects of types that are included in the main file. However, when

> > I try to create objects from the imported file, I get the following
error:
> >
> > java.lang.IllegalArgumentException in
> > org.apache.tuscany.sdo.util.DataObjectUtil.create
(DataObjectUtil.java:2549).
> >
> > The code to load the schema file is:
> >
> >   public static void initHelperContext () throws FileNotFoundException
> >   {
> >     hc = SDOUtil.createHelperContext();
> >
> >     XSDHelper xsdHelper = hc.getXSDHelper();
> >
> >     File f2 = new File ("c:\temp\schema.xsd");
> >     InputStream is2 = new FileInputStream (f2);
> >     xsdHelper.define(is2, f2.getAbsolutePath());
> >   }
> >
> > That's how the schema file gets imported:
> >
> >   <xsd:import namespace="<our namespace>"
schemaLocation="include.xsd"/>
> >
> > When I copy the definitions from the imported file into the main file,
> > then everything works fine...
> >
> > Any help is appreciated...
> >
> > Thanks
> > Thomas

Re: Problems with XSDHelper.define and schema file having import statements...

Posted by Frank Budinsky <fr...@ca.ibm.com>.
Hi Thomas,

Since you don't show what schema.xsd and include.xsd contain, and what type
you're trying to create when you get the error, it's very hard to guess
what the problem might be.

Things to check:

1) Is include.xsd in the same folder as schema.xsd (i.e., c:\temp)? It
should be.
2) What is the targetNamespace of the schema in schema.xsd? Is it different
from the namespace you're importing ("<our namespace>")? It should be
different.
3) What is the target namespace of the schema in include.xsd? Is it the
same as namespace you're importing ("<our namespace>")? It should be the
same.
4) Are you creating the type from the included schema using the imported
namespace ("<our namespace>") as the URI argument ? You should be.

Frank.

Thomas Trenz <th...@blue-elephant-systems.com> wrote on 07/27/2009
06:15:13 AM:

> Hello,
>
> I am using Apache Tuscany SDO 1.1.1 and I have a problem loading a
> schema file with an import statement. What happens is that I can create
> data objects of types that are included in the main file. However, when
> I try to create objects from the imported file, I get the following
error:
>
> java.lang.IllegalArgumentException in
> org.apache.tuscany.sdo.util.DataObjectUtil.create
(DataObjectUtil.java:2549).
>
> The code to load the schema file is:
>
>   public static void initHelperContext () throws FileNotFoundException
>   {
>     hc = SDOUtil.createHelperContext();
>
>     XSDHelper xsdHelper = hc.getXSDHelper();
>
>     File f2 = new File ("c:\temp\schema.xsd");
>     InputStream is2 = new FileInputStream (f2);
>     xsdHelper.define(is2, f2.getAbsolutePath());
>   }
>
> That's how the schema file gets imported:
>
>   <xsd:import namespace="<our namespace>" schemaLocation="include.xsd"/>
>
> When I copy the definitions from the imported file into the main file,
> then everything works fine...
>
> Any help is appreciated...
>
> Thanks
> Thomas