473,473 Members | 1,817 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

xml schema design

I have an xml schema that I am working on. I wanted to know if it was a
normal thing to do something like this:

1. Have a ZipCode simple type that has to be 5 characters long.
2. Have a StateCode simple type that has to be 2 characters long.
3. Have an Address complex type that has:
- Street (string)
- City (sgring)
- State (StateCode) [noted in item 2 above]
- ZipCode (ZipCode) [noted in item 1 above]
4. Have a Venue complex type that has the following:
- Name (string)
- Address (Address) [noted in item 3 above]
- PhoneNumber (string)
5. Have an element that can contain only 1 instance of the Venue complex
type.

Mar 26 '08 #1
8 1979
Andy B wrote:
I have an xml schema that I am working on. I wanted to know if it was a
normal thing to do something like this:

1. Have a ZipCode simple type that has to be 5 characters long.
2. Have a StateCode simple type that has to be 2 characters long.
3. Have an Address complex type that has:
- Street (string)
- City (sgring)
- State (StateCode) [noted in item 2 above]
- ZipCode (ZipCode) [noted in item 1 above]
4. Have a Venue complex type that has the following:
- Name (string)
- Address (Address) [noted in item 3 above]
- PhoneNumber (string)
5. Have an element that can contain only 1 instance of the Venue complex
type.
Sounds fine to me, you might additionally restrict zip code to five
digits, enumerate the possible state codes.

--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Mar 27 '08 #2
Sounds fine to me, you might additionally restrict zip code to five
digits, enumerate the possible state codes.
I forgot about the fact that I had ZipCode set to require 5 characters. I
want to make this a 5 digit number but cant find a length property for the
int or integer data type. How would I fix this? I have it set to ZipCode
(string) - length=5. You also said to make an enum for the state codes. How
exactly do I do this?


Mar 27 '08 #3
Andy B wrote:
>Sounds fine to me, you might additionally restrict zip code to five
digits, enumerate the possible state codes.

I forgot about the fact that I had ZipCode set to require 5 characters. I
want to make this a 5 digit number but cant find a length property for the
int or integer data type. How would I fix this? I have it set to ZipCode
(string) - length=5. You also said to make an enum for the state codes. How
exactly do I do this?
Straight from <URL:http://www.w3.org/TR/xmlschema-0/is this example:

<xsd:simpleType name="USState">
<xsd:restriction base="xsd:string">
<xsd:enumeration value="AK"/>
<xsd:enumeration value="AL"/>
<xsd:enumeration value="AR"/>
<!-- and so on ... -->
</xsd:restriction>
</xsd:simpleType>

As for the zip code, one way is with a regular expression pattern:
<xsd:simpleType name="zipType">
<xsd:restriction base="xsd:positiveInteger">
<xsd:pattern value="\d{5}"/>
</xsd:restriction>
</xsl:simpleType>

--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Mar 27 '08 #4
Why would it be a good idea to do an enum for the state codes instead of
just letting somebody typing it in just a string field?
"Martin Honnen" <ma*******@yahoo.dewrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl...
Andy B wrote:
>>Sounds fine to me, you might additionally restrict zip code to five
digits, enumerate the possible state codes.

I forgot about the fact that I had ZipCode set to require 5 characters. I
want to make this a 5 digit number but cant find a length property for
the int or integer data type. How would I fix this? I have it set to
ZipCode (string) - length=5. You also said to make an enum for the state
codes. How exactly do I do this?

Straight from <URL:http://www.w3.org/TR/xmlschema-0/is this example:

<xsd:simpleType name="USState">
<xsd:restriction base="xsd:string">
<xsd:enumeration value="AK"/>
<xsd:enumeration value="AL"/>
<xsd:enumeration value="AR"/>
<!-- and so on ... -->
</xsd:restriction>
</xsd:simpleType>

As for the zip code, one way is with a regular expression pattern:
<xsd:simpleType name="zipType">
<xsd:restriction base="xsd:positiveInteger">
<xsd:pattern value="\d{5}"/>
</xsd:restriction>
</xsl:simpleType>

--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/

Mar 27 '08 #5
Andy B wrote:
Why would it be a good idea to do an enum for the state codes instead of
just letting somebody typing it in just a string field?
In terms of the W3C schema language I suggested an _enumeration_ below:
><xsd:simpleType name="USState">
<xsd:restriction base="xsd:string">
<xsd:enumeration value="AK"/>
<xsd:enumeration value="AL"/>
<xsd:enumeration value="AR"/>
<!-- and so on ... -->
</xsd:restriction>
</xsd:simpleType>
Or are you now talking about a .NET enumeration defined with C# or VB.NET?

--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Mar 27 '08 #6
You have the right thing. Does it do the same thing a c# enum would do?
either restrict the strings that can be used, or make useful names for
meaningless numbers (like a c# enum does)?
"Martin Honnen" <ma*******@yahoo.dewrote in message
news:Om**************@TK2MSFTNGP04.phx.gbl...
Andy B wrote:
>Why would it be a good idea to do an enum for the state codes instead of
just letting somebody typing it in just a string field?

In terms of the W3C schema language I suggested an _enumeration_ below:
>><xsd:simpleType name="USState">
<xsd:restriction base="xsd:string">
<xsd:enumeration value="AK"/>
<xsd:enumeration value="AL"/>
<xsd:enumeration value="AR"/>
<!-- and so on ... -->
</xsd:restriction>
</xsd:simpleType>

Or are you now talking about a .NET enumeration defined with C# or VB.NET?

--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/

Mar 27 '08 #7
Andy B wrote:
You have the right thing. Does it do the same thing a c# enum would do?
either restrict the strings that can be used, or make useful names for
meaningless numbers (like a c# enum does)?
The simple type I posted is a restriction of xsd:string allowing only
the enumerated string values (e.g. "AK" or "AL") to be used.

--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Mar 28 '08 #8
Makes sense to me. I added all of the state codes to the schema.
"Martin Honnen" <ma*******@yahoo.dewrote in message
news:eT**************@TK2MSFTNGP03.phx.gbl...
Andy B wrote:
>You have the right thing. Does it do the same thing a c# enum would do?
either restrict the strings that can be used, or make useful names for
meaningless numbers (like a c# enum does)?

The simple type I posted is a restriction of xsd:string allowing only the
enumerated string values (e.g. "AK" or "AL") to be used.

--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/

Mar 28 '08 #9

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

Similar topics

1
by: Gregg Williams | last post by:
Hi--I am having a problem designing a schema to fit my XML data, and I'm hoping that someone can help. Essentially, I have a schema in mind and two target vocabularies for it, where one vocabulary...
5
by: Ralf Wahner | last post by:
Dear Masters of XML As I'm new to XML Schema I dare to ask a possibly recurring question: Given an element <elem> with two attributes @a and @b. The attributes are bound by the condition, that...
4
by: Gordon Dickens | last post by:
I have target xml to generate from schema. All of the XML instances have the same global element i.e. <base>. I would like to combine all of the schemas into a single schema where I could...
3
by: Kanchana D S | last post by:
Hi, I am trying to design the schema for an XML file. The approach that I am planning to follow is to have 2 XSD files, each containing some relevant information about the elements in the...
1
by: Jeff S | last post by:
Hello all, I'm trying to design a schema from which I can generate a typed dataset class. I'm having problems incorporating choice and enumerations in the schema and getting the xml results...
4
by: cmc | last post by:
I need some clarification to help me understand the DB2 strucure more. The questions are about "implicit schema" 1. This is a very interest concpet that DB2 let every user to create new schema...
3
by: Eric Lilja | last post by:
Hello again, I'm having a new problem converting a dtd to an xml schema. This once is a little bit more complicated than in my previous question. The following file validates correctly: <?xml...
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...
8
by: send.me.all.email | last post by:
Hi experts, which approaches would you suggest for: - Reading a database schema (tables, fields, relationships) from SQL Server 2005? - Visualizing the DB schema? For developing a DB tool...
12
by: Summercoolness | last post by:
I wonder instead of just brainstorming, there probably is a very standard and a simple way to do database schema design. let's say we are doing a website. the user can go over and type in the...
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
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...
1
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.