473,406 Members | 2,705 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.

HELP - How to restrict elements in instance doc?

Hi,

Can anyone tell me if it is possible to create a XSD schema document
that will only allow certain elements to be displayed as available
within the instance document depending on say a parameter the user has
entered in the parent element?

For example:

In the instance document I have the following...

<file-layout xmlns="test"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="test file:/D:/test.xsd"
name="myLayout"
locale="en_GB"
lastModifiedBy="Joe Bloggs"
type="BINARY">

'type' is a required attribute. Depending on if the user selects ASCII
or BINARY from the selection I want the instance document to then
display an appropriate child element.

For example, there may be a choice of either <ascii-parse> or
<binary-parse> as child elements. Both are distinctly different, and I
want the schema document (using the choice made by the user when
selecting 'type') to manage the validity of the instance document and
not have my code that reads in the instance document to have to check
to see if the user has made a mistake by say selecting type=ASCII and
then selecting <binary-parse> as the child element.

Any help would be appreciated.
Thanks.

Apr 5 '06 #1
1 1332
da*******@hotmail.com wrote:
Can anyone tell me if it is possible to create a XSD schema document
that will only allow certain elements to be displayed as available
within the instance document depending on say a parameter the user has
entered in the parent element?
It's possible for an instance document to explicitly say what type a
given element is to be treated as, using the xsi:type attribute.

If you want some other attribute to change the element's type as a
side-effect... I don't think that's supported. The type sets the legal
content, not vice versa.
For example, there may be a choice of either <ascii-parse> or
<binary-parse> as child elements. Both are distinctly different, and I
want the schema document (using the choice made by the user when
selecting 'type') to manage the validity of the instance document and
not have my code that reads in the instance document to have to check
to see if the user has made a mistake by say selecting type=ASCII and
then selecting <binary-parse> as the child element.


Personally, I'd fix that by not allowing this information to be
specified in a way that can conflict. Discard the type attribute and
just let the choice of element specify how its contents are to be processed.

--
() ASCII Ribbon Campaign | Joe Kesselman
/\ Stamp out HTML e-mail! | System architexture and kinetic poetry
Apr 6 '06 #2

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

Similar topics

0
by: Piers Chivers | last post by:
Hi, I need to restrict the allowed included elements dependent upon the value of another element. How do I do this using XML Schema? For example, the XML <Petshop> <Kind>Dog</Kind>...
6
by: Lindy | last post by:
I'm using VB .Net and am brand new to XML. I need to create an XML file with the following lines: <?xml version="1.0" encoding="UTF-8" ?> - <HC_DATA...
16
by: Simon | last post by:
I am a programming student and have recently missed two weeks of school due to a serious injury in a car accident. I am completing all of my assignments (via Labs) but have come across the...
1
by: Maksim | last post by:
Trying to find out a way how to restrict value of the element by name of an element, it might be not even possible, but anyhow. Let's consider following snippet: <xs:element name="tag1"...
4
by: Vijay Kumar R Zanvar | last post by:
Greetings, Are the following inferences of mine correct? 1. #include <string.h> char *strcpy(char * restrict s1, const char * restrict s2); a. s1 != s2 b. That means,
7
by: tweak | last post by:
Can someone give me a short example as how to best use this keyword in your code? This is my understanding: by definition restrict sounds like it is suppose to restrict access to memory...
33
by: aaron | last post by:
I have a question in my class.. hoping to get some help I need to create a program that will print firstName middleName lastName then their initials User will input: John Smith Doe Output:...
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,...
4
by: Joshua Mostafa | last post by:
Hi there. I have a question regarding restrictions in an XML Schema definition. My XML contains a structure like this: <fruit-bowl> <fruit name="apple" /> <fruit name="pear" /> <fruit...
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: 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
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: 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
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...
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.