473,406 Members | 2,378 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,406 software developers and data experts.

Best practice Questions

Hi,

I am in the process of creating a schema definition to validate some
XML data that will look like the following:

ProductA

SubProductA
SubProductB
SubProductC

ProductB

SubProductX
SubProductY
SubProductZ

Now I would like if possible to create a simple type called say
"Product" which has Enum content of:

Enum:"ProductA"
Enum:"ProiductB"
......
......

Then also have another simple type for the "SubProduct" with it's Enum
values as follows:

Enum:"SubProductA"
Enum:"SubProductB"
EnumL:"SubProductX"
......
I am struggling in deciding the best way to structure the complex Type
so that the Structure is enforcing the fact that SubProductX can only
be a SubProduct of ProductB......

I would like the flexability to be able to simply add a new
ProductType and enforce the relevant subtypes allowed to be detailed
with them.

Am fairly new to XSD (3 Weeks in) Any help much appreciated.

Apr 20 '07 #1
3 1568
On 20 Apr, 16:11, jlam...@googlemail.com wrote:
I am in the process of creating a schema definition to validate some
XML data that will look like the following:
Just don't. This isn't an appropriate concept to try and validate
with schema.
Sadly it's too difficult to spend the full time explaining, given
today's workload. Briefly though:

Schema / DTD validates XML _structure_ and not 'data' content. If you
follow your approach here, you're pushing 'data' items into the
structure by using them to generate element names. This would also
permit DTD / Schema validation ("permit", not "make it easy") of your
data rules. However this is also a use of XML that's usually a bad
idea -- you've implemented something that's changeable in practice
(product structure) and nailed it down with something that really
implies long-term stability (XML Schema).

A better approach would be a simple XML Schema based on just <Product>
as an element and keeping ProductA, ProductB etc. well away from this.
This does make Schema-based validation difficult though and starts to
look like a task for OWL instead. Even then, it's still easy to get to
a stage of complexity where it becomes impossible to validate
automatically. Better than fluid element names though.

Apr 20 '07 #2
I am struggling in deciding the best way to structure the complex Type
so that the Structure is enforcing the fact that SubProductX can only
be a SubProduct of ProductB......
That sounds like it ought to be something enforced by your application
code, at least as much because it will change dynamically over time
based on other tables of product relationships as because it'll be a
pain to do in schemas. (You don't want to have to change the schema when
you introduce a new product.)

Schemas are used to define the structure of a language. What you say
with the language is a separate question.

Use the schema system to define the structure of your documents, and
reasonable ranges for their values... but for nontrivial applications,
don't assume it's the only check that will be performed. Your
applications will have to continue applying semantic checks if you want
to make sure the document means something reasonable.
(By analogy: A schema for English would conclude that "colorless green
ideas sleep furiously" is a perfectly reasonable statement, because all
the words are valid and the sentence structure is acceptable. The fact
that it's nonsense has to be dealt with at another level.)

--
() ASCII Ribbon Campaign | Joe Kesselman
/\ Stamp out HTML e-mail! | System architexture and kinetic poetry
Apr 20 '07 #3
On Apr 20, 8:54 pm, Joe Kesselman <keshlam-nos...@comcast.netwrote:
I am struggling in deciding the best way to structure the complex Type
so that the Structure is enforcing the fact that SubProductX can only
be a SubProduct of ProductB......

That sounds like it ought to be something enforced by your application
code, at least as much because it will change dynamically over time
based on other tables of product relationships as because it'll be a
pain to do in schemas. (You don't want to have to change the schema when
you introduce a new product.)

Schemas are used to define the structure of a language. What you say
with the language is a separate question.

Use the schema system to define the structure of your documents, and
reasonable ranges for their values... but for nontrivial applications,
don't assume it's the only check that will be performed. Your
applications will have to continue applying semantic checks if you want
to make sure the document means something reasonable.

(By analogy: A schema for English would conclude that "colorless green
ideas sleep furiously" is a perfectly reasonable statement, because all
the words are valid and the sentence structure is acceptable. The fact
that it's nonsense has to be dealt with at another level.)

--
() ASCII Ribbon Campaign | Joe Kesselman
/\ Stamp out HTML e-mail! | System architexture and kinetic poetry
Thanks very much for your responses i'll take that on board.

Apr 21 '07 #4

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

Similar topics

136
by: Matt Kruse | last post by:
http://www.JavascriptToolbox.com/bestpractices/ I started writing this up as a guide for some people who were looking for general tips on how to do things the 'right way' with Javascript. Their...
5
by: Søren Reinke | last post by:
Hi there I am working on a program where the user should be able to import some CSV files. With my set of test data, it takes about 2 minutes to import, while it is importing the program sort...
1
by: Vincent V | last post by:
Hey i am just starting a new project and from the start i want to make sure my app is as Object Orientated as possible I have a couple of questions in relation to this Question 1: Should i...
10
by: Mike Logan | last post by:
I am using the "contract first" design methodology. Contract First is design the WSDL first then design the server and client. However I must design my XSD/XML Schema before anything. I am...
16
by: Rex | last post by:
Hi All - I have a question that I think MIGHT be of interest to a number of us developers. I am somewhat new to VIsual Studio 2005 but not new to VB. I am looking for ideas about quick and...
4
by: =?Utf-8?B?bW9mbGFoZXJ0eQ==?= | last post by:
In VB6, we created a number of ActiveX DLLs that all shared a similar interface. The main application would load these in dynamically (late-bound.) This worked well for our situation because we...
13
by: G | last post by:
Hello, Looking for opinions on a fairly simple task, new to ASP.net (C#) and want to make sure I do this as efficiently as possible. I have a web based form, and I need to run some SQL before...
3
by: samadams_2006 | last post by:
Hello, I'm interested in taking the following exam for an upcoming job. Exam 70-315: Developing and Implementing Web Applications with Microsoft Visual C#â„¢ .NET and Microsoft Visual Studio...
1
by: Robert Bravery | last post by:
HI all, Where can I find some best practices on web surveys and also wizards. Things like maximum questions per page, lenght of questions, type of answers given, Ie interativty like dropdowns...
1
by: =?Utf-8?B?Y2hhcmxpc2E=?= | last post by:
We are developing a Web Application in which we would like to utilize the System.Web.Profile object. Unfortunately, .NET does not create the infrastructure for Profiles in a Web Application, only...
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
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
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
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.