GeeCON Prague 2014*
The moose likes Web Services and the fly likes xml schema question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Web Services
Bookmark "xml schema question" Watch "xml schema question" New topic
Author

xml schema question

Adam Al
Greenhorn

Joined: Oct 09, 2012
Posts: 1
Hello
I am running into this problem with xml schema, here is my issue
I have 3 schema(s), each with different name space. One schema "A" has 2 elements, one is header and the other is "Data".
Data can be any of 2 schema(s) (one or the other) , since these schema(s) do not have the same name space , I used import, but still having problem
Here are sample of I am trying to do , any help will be appreciate it. (I need this to be able use jaxb)
<?xml version="1.0" ?>
<xs:schema targetNamespace="http://testA.com/A.xsd"
xmlns:cmr="http://testA.com/A.xsd"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"
xmlns:itmB=http://testB.com/B.xsd
xmlns:itmC="http://testC.com/C.xsd"

attributeFormDefault="qualified" elementFormDefault="qualified">

<xs:import namespace="http://testB.com/B.xsd"
schemaLocation="B.xsd"/>
<xs:import namespace="http://testC.com/C.xsd"
schemaLocation="C.xsd"/>

<xs:element name="A">
<xs:complexType>
<xs:sequence>
<xs:element name="Header" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="message-class" form="unqualified" type="xs:string" />
<xs:attribute name="message-id" form="unqualified" type="xs:long" />
<xs:attribute name="message-date" form="unqualified" type="xs:dateTime" />
</xs:complexType>
</xs:element>
<xs:element name="Data" minOccurs="1" maxOccurs="1">
<xs:complexType>
<xs:choice>
<xs:element name="B" type="itmB:B"/>
<xs:element name="C" type="itmC:C"/>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>


Also here is sample of the schema B

<xs:schema id="B"
targetNamespace="http://testB.com/B.xsd"
elementFormDefault="qualified" attributeFormDefault="qualified"
xmlns="http://testB.com/B.xsd"
xmlns:mstns="http://testB.com/B.xsd"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xs:element name="B" msdata:IsDataSet="true">
<xs:complexType>
<xs:choice maxOccurs="unbounded">
<xs:element name="Title">
<xs:complexType>
<xs:sequence>
.
.
Rizwan Patel
Ranch Hand

Joined: Jan 03, 2008
Posts: 59

What error you are getting when using JAXB?


scjp 1.5, OCPJWSD 5
g tsuji
Ranch Hand

Joined: Jan 18, 2011
Posts: 520
    
    3
In any case, this:
<xs:element name="B" type="itmB:B"/>

should be read:

Same for itmC:C if the schema C follows the same pattern as schema B. The reason basically is that you have defined global element B rather than global type B in the schema B.
david fields
Greenhorn

Joined: Jun 06, 2011
Posts: 5
this schema tutorial will help.

http://www.liquid-technologies.com/Tutorials/XmlSchemas/XsdTutorial_01.aspx
 
GeeCON Prague 2014
 
subject: xml schema question