473,401 Members | 2,127 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,401 software developers and data experts.

XSD One to Many Schema

Bob
Hi,
I am new to XML schemas.
I am going to be moving a text file from machine A to machine B. (My app on
both)
So I figured I would construct an XSD schema of the file layout (which in
itself is a rolling around in my head.)
Anyway I see this file having a one contains many structure.
ie There is a Batch element which will contain a number of BatchMember
Elements.
I can see how to construct this in the XML editor.
I want
<FileList xmlns="http://tempuri.org/MyFile.xsd>
<Header> some header stuff <\Header>
<Batch>
<BatchNum>1</BatchNum>
<BatchMember>1</BatchMember>
<BatchMember>2</BatchMember>
</Batch>
<Batch>
<BatchNum>2</BatchNum>
<BatchMember>1</BatchMember>
<BatchMember>2</BatchMember>
</Batch>
</FileList

The closest I have come is treating Batch and BatchMember like a couple of
database tables with a parent child relationship. But this entails adding a
foreign key field to the BatchMember Element.
This approach also falls short because I want to put multiple batches in the
file.
Is there way to tackle this?
Thanks
Bob

Mar 25 '06 #1
2 1567
Maybe something like so. Note that the BatchNum might be redundant, since
you can rely on XML order.

<?xml version="1.0" encoding="utf-8" ?>
<xs:schema id="MyFile.xsd"
targetNamespace="http://tempuri.org/MyFile.xsd"
elementFormDefault="qualified"
xmlns="http://tempuri.org/MyFile.xsd"
xmlns:xs="http://www.w3.org/2001/XMLSchema">

<xs:element name="FileList" type="FileListType" />

<xs:complexType name="FileListType">
<xs:sequence>
<xs:element name="Header" type="xs:string" />
<xs:element name="Batch" type="BatchType" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>

<xs:complexType name="BatchType">
<xs:sequence>
<xs:element name="BatchNum" type="xs:int" />
<xs:element name="BatcmMember" type="xs:string" maxOccurs="unbounded"
/>
</xs:sequence>
</xs:complexType>

</xs:schema>
"Bob" <bo*@nowhere.com> wrote in message
news:Ob****************@TK2MSFTNGP12.phx.gbl...
Hi,
I am new to XML schemas.
I am going to be moving a text file from machine A to machine B. (My app
on
both)
So I figured I would construct an XSD schema of the file layout (which in
itself is a rolling around in my head.)
Anyway I see this file having a one contains many structure.
ie There is a Batch element which will contain a number of BatchMember
Elements.
I can see how to construct this in the XML editor.
I want
<FileList xmlns="http://tempuri.org/MyFile.xsd>
<Header> some header stuff <\Header>
<Batch>
<BatchNum>1</BatchNum>
<BatchMember>1</BatchMember>
<BatchMember>2</BatchMember>
</Batch>
<Batch>
<BatchNum>2</BatchNum>
<BatchMember>1</BatchMember>
<BatchMember>2</BatchMember>
</Batch>
</FileList

The closest I have come is treating Batch and BatchMember like a couple of
database tables with a parent child relationship. But this entails adding
a
foreign key field to the BatchMember Element.
This approach also falls short because I want to put multiple batches in
the
file.
Is there way to tackle this?
Thanks
Bob

Mar 25 '06 #2
Bob
Don't Worry,
Problem Solved.
Bob
"Bob" <bo*@nowhere.com> wrote in message
news:Ob****************@TK2MSFTNGP12.phx.gbl...
Hi,
I am new to XML schemas.
I am going to be moving a text file from machine A to machine B. (My app on both)
So I figured I would construct an XSD schema of the file layout (which in
itself is a rolling around in my head.)
Anyway I see this file having a one contains many structure.
ie There is a Batch element which will contain a number of BatchMember
Elements.
I can see how to construct this in the XML editor.
I want
<FileList xmlns="http://tempuri.org/MyFile.xsd>
<Header> some header stuff <\Header>
<Batch>
<BatchNum>1</BatchNum>
<BatchMember>1</BatchMember>
<BatchMember>2</BatchMember>
</Batch>
<Batch>
<BatchNum>2</BatchNum>
<BatchMember>1</BatchMember>
<BatchMember>2</BatchMember>
</Batch>
</FileList

The closest I have come is treating Batch and BatchMember like a couple of
database tables with a parent child relationship. But this entails adding a foreign key field to the BatchMember Element.
This approach also falls short because I want to put multiple batches in the file.
Is there way to tackle this?
Thanks
Bob

Mar 25 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Russell Thamm | last post by:
Hi, my application uses several XML documents. I want to know if there is any way to define identity constraints across documents. eg Doc A
0
by: mat | last post by:
I would like to create a schema for a document where I would have complex elements of the sort <entry type='initial'> <reason>...</reason> <t>...</t> </entry> <entry type='other'>...
4
by: Iain A. Mcleod | last post by:
Hi I'm stuck with the following schema validation problem in VS.NET 2003: I have two types of xml document and related schema: project and projectCollection. A projectcollection is just a set...
1
by: Mr. Almenares | last post by:
Hello: I’m trying to do a schema with recurrent structure for a Book like a Node can have many Nodes inside or One leave. So, the leaves have an attribute that is Identifier. My goal is define...
3
by: farseer | last post by:
Hello, i have a schema which also imports the XHTML schema: <xsd:import namespace="http://www.w3.org/1999/xhtml" schemaLocation="http://www.w3.org/2002/08/xhtml/xhtml1-strict.xsd"/> This...
7
by: Robert Stearns | last post by:
I ran the following bit of SQL and my PRIMARY KEY wound up in schema SYSIBM called SQL.... not schema is3 called primary. The index registation did wind up there. Obviously there's something I...
1
by: Jana | last post by:
Is there an XML-editor that can assist you in marking up the data in an urformatted text document, such that you mark the data and then right-click to access the Schema you have assigned, and...
3
by: Michael | last post by:
If I come up with an XML Schema, do I own the intellectual propertyrights for that schema? Can I legally restrict others from using that schema? I'm in the UK if that makes any difference...
1
by: situ | last post by:
Hello all, What is the limitation for the number of schema per database, how many schema we can have for a database. Thanks situ
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.