On more thing that I forgot to mention is that you don't actually need to 
call XSDHelper.define() for base.xsd because it will be automatically 
defined when you define simple.xsd (because of the import).

Frank.

"emiliano grigis" <[EMAIL PROTECTED]> wrote on 12/21/2006 05:35:15 
AM:

> Hi,
> I have a problem with an xml file based on a schema with a type that is
> imported from another schema. I think that the problem it's into the
> schemaLocation parameter on the define method.
> 
> 
> Of course if I use the value null for both the schemaLocation, like:
> 
>             XSDHelper.INSTANCE.define(baseXsd, null);
>             XSDHelper.INSTANCE.define(sampleXsd, null);
> 
> then I receive a
> 
> FeatureNotFoundException: Feature 'baseElement' not found. 
(http:///temp.xml,
> 4, 18)
> 
> exception when loading the xml document.
> 
> 
> If I specify the schemaLocation option like this:
> 
>             XSDHelper.INSTANCE.define(baseXsd, "
> http://www.example.org/BaseSchema";);
>             XSDHelper.INSTANCE.define(sampleXsd, null);
> 
> then I have a
> 
> java.lang.IllegalArgumentException:
> org.apache.tuscany.sdo.util.resource.SDOXMLResourceImpl
> 
> without further explanations.
> 
> 
> Many thanks in advance
> Emiliano
> 
> 
> The Java code:
> 
>             //base.xsd
>             //Schema with only a type definition
>             InputStream baseXsd = Thread.currentThread()
>                     .getContextClassLoader().getResourceAsStream(
>                             "base.xsd");
> 
>             //sample.xsd
>             //Schema that import the type definition from the other xsd
>             InputStream sampleXsd = Thread.currentThread()
>                     .getContextClassLoader().getResourceAsStream(
>                             "sample.xsd");
> 
>             //sample.xml
>             //document conform to the sample.xsd
>             InputStream sampleXml = Thread.currentThread()
>                     .getContextClassLoader().getResourceAsStream(
>                             "sample.xml");
> 
>             //Load the Schemas
>             XSDHelper.INSTANCE.define(baseXsd, "
> http://www.example.org/BaseSchema";);
>             XSDHelper.INSTANCE.define(sampleXsd, null);
>             System.out.println("-------------->>> Schemas read");
> 
>             //Load xml
>             XMLDocument xDoc = XMLHelper.INSTANCE.load(sampleXml);
>             System.out.println("-------------->>> Xml read");
> 
> 
> The base.xsd source:
> 
> <?xml version="1.0" encoding="UTF-8"?>
> <schema xmlns="http://www.w3.org/2001/XMLSchema"; targetNamespace="
> http://www.example.org/BaseSchema"; xmlns:base="
> http://www.example.org/BaseSchema"; >
>     <complexType name="baseType">
>         <sequence>
>             <element name="baseElement" type="string" minOccurs="1"
> maxOccurs="1"/>
>         </sequence>
>     </complexType>
> </schema>
> 
> 
> The sample.xsd source:
> 
> <?xml version="1.0" encoding="UTF-8"?>
> <schema xmlns="http://www.w3.org/2001/XMLSchema"; targetNamespace="
> http://www.example.org/SampleSchema"; xmlns:sample="
> http://www.example.org/SampleSchema"; xmlns:base="
> http://www.example.org/BaseSchema";>
>     <import namespace="http://www.example.org/BaseSchema"; 
schemaLocation="
> base.xsd"/>
>     <complexType name="sampleType">
>         <sequence>
>              <element name="sampleElement" 
type="base:baseType"></element>
>         </sequence>
>     </complexType>
>     <element name="myElement" type="sample:sampleType"></element>
> </schema>
> 
> 
> The sample.xml source:
> 
> <?xml version="1.0" encoding="UTF-8"?>
> <sample:myElement xmlns:base="http://www.example.org/BaseSchema";
> xmlns:sample="http://www.example.org/SampleSchema"; xmlns:xsi="
> http://www.w3.org/2001/XMLSchema-instance"; xsi:schemaLocation="
> http://www.example.org/SampleSchema sample.xsd
> http://www.example.org/BaseSchema base.xsd ">
>   <sampleElement>
>     <baseElement>this is my content</baseElement>
>   </sampleElement>
> </sample:myElement>


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

Reply via email to