473,388 Members | 1,824 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,388 software developers and data experts.

Advice on ways to extend a type using XSD

Say i've got a type that appears in a request... say it represents a
shipment. I want it to contain things like from and to address elements
as well as a sequence of the pieces being shipped.

Say the operation is supposed to calculate the cost to ship each piece.
I would like the response type to look just like the request type but
with a price element under each of the item types. For example:

Request:
<shipment>
<from/>
<to/>
<pieces>
<piece>
<weight>100</weight>
</piece>
<piece>
<weight>5</weight>
</piece>
</pieces>
</shipment>

Response:
<shipment>
<from/>
<to/>
<pieces>
<piece>
<weight>100</weight>
<cost>10.00</cost>
</piece>
<piece>
<weight>5</weight>
<cost>5.00</cost>
</piece>
</pieces>
</shipment>

It would be great if I could easily extend the request type to turn it
into the response type but I'm not sure there is an easy way to do that.

Any thoughts?

Jul 20 '05 #1
2 1489


Charles Fineman wrote:
Say i've got a type that appears in a request... say it represents a
shipment. I want it to contain things like from and to address elements
as well as a sequence of the pieces being shipped.

Say the operation is supposed to calculate the cost to ship each piece.
I would like the response type to look just like the request type but
with a price element under each of the item types. For example:

Request:
<shipment>
<from/>
<to/>
<pieces>
<piece>
<weight>100</weight>
</piece>
<piece>
<weight>5</weight>
</piece>
</pieces>
</shipment>

Response:
<shipment>
<from/>
<to/>
<pieces>
<piece>
<weight>100</weight>
<cost>10.00</cost>
</piece>
<piece>
<weight>5</weight>
<cost>5.00</cost>
</piece>
</pieces>
</shipment>

It would be great if I could easily extend the request type to turn it
into the response type but I'm not sure there is an easy way to do that.


One possible way is to have an element with minOccurs="0":
<xs:element name="pieces">
<xs:complexType>
<xs:sequence>
<xs:element name="piece" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="weight" type="xs:double" />
<xs:element name="cost" minOccurs="0" maxOccurs="1"
type="xs:double" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>

That way you can have <weight> and <cost> children or only a <weight> child.

--

Martin Honnen
http://JavaScript.FAQTs.com/

Jul 20 '05 #2
Agreed, but I'm hoping to keep the typing as "strong" as possible. It's
clear that I can extend the immediate children of the type (using
xs:extension) but it does not look like I can extend, say, the
grandchildren.

I would rather not define a ton of global types just for the purposes of
extension (is there a way to create global types that are local to the
file?). I could also use groups and just define a completely separate
complex type (but that's effectively the same as using extension in this
case I believe).

Martin Honnen wrote:


Charles Fineman wrote:
Say i've got a type that appears in a request... say it represents a
shipment. I want it to contain things like from and to address
elements as well as a sequence of the pieces being shipped.

Say the operation is supposed to calculate the cost to ship each
piece. I would like the response type to look just like the request
type but
with a price element under each of the item types. For example:

.... EDITED OUT ....

It would be great if I could easily extend the request type to turn it
into the response type but I'm not sure there is an easy way to do that.

One possible way is to have an element with minOccurs="0":
<xs:element name="pieces">
<xs:complexType>
<xs:sequence>
<xs:element name="piece" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="weight" type="xs:double" />
<xs:element name="cost" minOccurs="0" maxOccurs="1"
type="xs:double" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>

That way you can have <weight> and <cost> children or only a <weight>
child.


Jul 20 '05 #3

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

Similar topics

75
by: Howard Nease | last post by:
Hello, everyone. I would appreciate any advice that someone could give me on my future career path. Here is my situation: I am a bright Junior in a very well-respected private high school, taking...
1
by: Mike Chamberlain | last post by:
Hi all. I'm trying to extend the Microsoft Enterprise Library Data Access Application Block (http://msdn.microsoft.com/library/en-us/dnpag2/html/daab.asp?frame=true) to work with a Borland...
2
by: BCM | last post by:
I've been asked to display some meter data on the web and I need preliminary advice. We have several hundred meters on site, with a system that writes out xml files at 10 second intervals...
6
by: jk | last post by:
Looking through WebUIValidation.js, I discovered that the standard validators don't cater for non-numeric date formats (e.g. dd-MMM-yyyy) which I would like to do To keep code to a minimum, I...
13
by: Alan Silver | last post by:
Hello, MSDN (amongst other places) is full of helpful advice on ways to do data access, but they all seem geared to wards enterprise applications. Maybe I'm in a minority, but I don't have those...
8
by: george.leithead | last post by:
Hi all, I'm looking for some advice on how best to achitect the following requirement. I'm basically writing a Fantasy Football (FF) Web site, and would like to have it fully OO and have it...
53
by: Hexman | last post by:
Hello All, I'd like your comments on the code below. The sub does exactly what I want it to do but I don't feel that it is solid as all. It seems like I'm using some VB6 code, .Net2003 code,...
232
by: robert maas, see http://tinyurl.com/uh3t | last post by:
I'm working on examples of programming in several languages, all (except PHP) running under CGI so that I can show both the source files and the actually running of the examples online. The first...
7
by: shapper | last post by:
Hello, Consider I have a String: Dim MyString As String = "Hello" or an Integer: Dim MyInteger As Integer = 100
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...

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.