Win a copy of Zero to AI - A non-technical, hype-free guide to prospering in the AI era this week in the Artificial Intelligence and Machine Learning forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Paul Clapham
  • Bear Bibeault
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Jj Roberts
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • salvin francis
  • Scott Selikoff
  • fred rosenberger

xml schema question

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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>
.
.
 
Ranch Hand
Posts: 59
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What error you are getting when using JAXB?
 
Ranch Hand
Posts: 729
7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
this schema tutorial will help.

http://www.liquid-technologies.com/Tutorials/XmlSchemas/XsdTutorial_01.aspx
 
You got style baby! More than this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic