473,769 Members | 6,286 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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:"SubProduc tA"
Enum:"SubProduc tB"
EnumL:"SubProdu ctX"
......
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 1579
On 20 Apr, 16:11, jlam...@googlem ail.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
9447
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 code was littered with document.all and eval, for example, and I wanted to create a practical list of best practices that they could easily put to use. The above URL is version 1.0 (draft) that resulted. IMO, it is not a replacement for the FAQ,...
5
7385
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 of freezes. Therefore i would like to open a little window with a progress bar in it that shows how far the import has come.
1
2279
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 Struction my solution in numerous projects ie 1. Webpage Files(ui) 2. Classes
10
1990
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 developing my schema now. I have a version on my schema. However once I start the server side code, how is the server now that the right "complexType" is being passed? What happens if this complexType my web service consumes needs to be...
16
2817
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 efficient navigating within Visual Studio 2005. Let's say your project (or solution) has dozens of forms and hundreds or even thousands of routines. Two Questions: 1) BUILT-IN to Visual Studio 2005. What ideas do you have to quickly
4
2899
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 could update the DLLs independently of the main EXE, and performance was not a problem. We want to do the same thing in C# (at least test it), but we are not exactly clear what the best practice is. We would prefer to do something similar, but we...
13
2570
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 submit, which determines exactly where to send the form contents. The table of "receipients" could contain in the region of 3,500 recipients but is more likely to contain up to 1,000. Table structure:
3
3711
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 .NET. Since the job is being offered soon I need to know the "quickest" and "best" way to prepare for this exam. Are there any books, practice exams, etc. that are considered "THE BEST"?
1
1184
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 and chackbox, and radiobuttons. I have a possible client, but his original survey has like 100 questions per page. I want to be able to show him whether or not this is the best way of doing things. Do users like scrolling through hundreds of...
1
2127
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 in Web Site projects. Is there a best practice for utilizing profiles in a Web Application?
0
9587
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9423
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10211
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9993
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9863
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7406
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6672
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
2
3561
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2815
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.