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

Schema: Change properties of inherited elements without listing them again

Hi,
I am having trouble describing in a schema that elements can be
mandatory in one part and not mandatory in another part of the xml
document. Here is a sample xml file

<Model:Templates>
<Node:Template Node:nodeId="nodeID">
<Node:Name Node:Comment="">Name</Node:Name>
<Node:Name2 Node:Comment="">Name</Node:Name2>
...
<Node:Name100 Node:Comment="">Name</Node:Name100>
</Node:Template>
</Model:Templates>
<Model:Processes>
<Node:Process Node:template="nodeID" Node:nodeId="nodeID2">
<Node:Name Node:Comment="">Overwrite</Node:Name>
<Node:Name99 Node:Comment="">Overwrite</Node:Name99>
</Node:Process>
</Model:Processes>
Node:Process has exactly the same contents except that the childs are
not mandatory. I call it the "mandatory difference"

What I would like to have and can not accomplish with schemas:

1. Node:Template and Node:Process should both be Node:Node, but schema
should still state that "mandatory difference"

2. Describe in the schema the "mandatory difference" without the need
to repeat all Node:Name´s with some trick like "group, extension,
restriction, all". I tried them all but did not succeed.

I think the main problem is that changing the mandatory is only
possible in the name-elements, so changing this property always
requires to list the name-elements again. I thought the minOccurence
of the <all> element could globaly state the mandatory property but
unfortunately it did not.

Here is an example for <all>
<group name="NodeGroup">
<!--minOccurs does not help here-->
<all minOccurs="0">
<element name="Name" type="string"/>
<element name="Name2" type="string"/>
...
<element name="Name3" type="string"/>
</all>
</group>
<element name="Node" type="Node:Node"/>
<complexType name="Node">
<group ref="Node:NodeGroup"/>
</complexType>
<element name="Template" type="Node:Template"/>
<complexType name="Template">
<group ref="Node:NodeGroup"/>
</complexType>
<element name="Process" type="Node:Process"/>
<complexType name="Process">
<complexContent>
<restriction base="Node:Node">
<!--minOccurs does not help here-->
<group ref="Node:NodeGroup" minOccurs="0"/>
<attribute name="nodeId" type="string" use="required"/>
<attribute name="template" type="string" use="optional"/>
</restriction>
</complexContent>
</complexType>
<complexType name="AttrElement">
<simpleContent>
<extension base="string">
<attribute name="Comment" type="string" use="optional"/>
</extension>
</simpleContent>
</complexType>

Is there any way to accomplish this?

Alex
Jul 20 '05 #1
1 1832
mr*****@hotmail.com (Alex Sab) writes:
Hi,
I am having trouble describing in a schema that elements can be
mandatory in one part and not mandatory in another part of the xml
document. ...
...
Node:Process has exactly the same contents except that the childs are
not mandatory. I call it the "mandatory difference"

What I would like to have and can not accomplish with schemas:


Well, actually, you can. What you are looking for, I think,
is that in one context an element should have one type (in
which things are mandatory), and in another the same element
(or: an element with the same name) should have a similar
type (in which things are optional). Since XML Schema
allows local bindings of element names to types, this
is not hard to do.

A simple example of the problem and some discussion of how to address
it are given at http://www.w3.org/2000/04/26-csrules.html

I hope this helps.

-C. M. Sperberg-McQueen
World Wide Web Consortium

Jul 20 '05 #2

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

Similar topics

1
by: Brett Selleck | last post by:
I would like to start collecting Metadata on my XML schemas. I have searched the web for a method of automatically extracting Metadata from an XSD file and have come up empty handed. Basically what...
2
by: Mark Constant | last post by:
All I want to do is have a xml file like this <Entertainment> <Movie> <Title>(Title Here)</Title> <Rating>(Rating Here)</Title> </Movie> <Movie> <Title>(Title Here)</Title> <Rating>(Rating...
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...
14
by: Reply Via Newsgroup | last post by:
Folks, Say I have a table, ten columns, ten rows - Each with a word in it. I want to change the values of some/all of the cells in the table via a hyperlink. How do I reference each cell and...
3
by: Rohit Sharma | last post by:
Hi all.. ..NET + MSXML platform....VB Need to build a list of all the entities and attributes to allow the user to do search...how can i do that from the schema ?? Cheers Rohit
2
by: Dan Shookowsky | last post by:
I'm trying to write a schema that allows me to substitute entensions for a base type. The schema (included below) defines a StepType and an AnnouncementStepType that is an extension of the base...
3
by: Chris Lieb | last post by:
I am new to XML Schema and am running into a bit of a snag. I have defined an XML-based scripting language for an updater program that I am working on. I would like to make a schema for this...
3
by: C.W.Holeman II | last post by:
I am new to using XML. I am using Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1. In my test I am attempting to have the style sheet:...
9
by: mstilli | last post by:
Hi, I am trying to use schema for server side validation using xerces to catch the validation errors. validating this XML: <Content4> <textarea13></textarea13>...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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: 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: 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
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.