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

sub-elements with empty context vs. element text

What are the advantages/disadvantages of using a choice of a several
"sub-"elements with empty content (and no attributes) vs. simple
content. Here's an example:

Using simple content:
<process>xyz</process>

Using empty content sub-element:
<process><xyz/></process>

Assume in both cases the xyz part has a limited domain, i.e., it can
be xyz, abc, or efg, but no other values make sense. Of course some
day, I might want to extend it to include rst.

The XML Schema for the empty content sub-element version looks
something like this:

<xsd:complexType name="ProcessType>
<xsd:complexContent/>
</xsd:complexType>

This defines ProcessType as having empty content. I can then use this
to define the types of processing I want to allow as follows:

<xsd:element name = "process" type="ProcessChoiceType"/>

<xsd:complexType name="ProcessChoiceType">
<xsd:complexContent>
<xsd:choice minOccurs="1" maxOccurs="1">
<xsd:element name="abc" type="ProcessType"/>
<xsd:element name="efg" type="ProcessType"/>
<xsd:element name="xyz" type="ProcessType"/>
<xsd:element name="extented_process" type="ProcessType"
abstract="true"/>
</xsd:choice>
</xsd:complexContent>
</xsd:complexType>

The abstract element extended_process is added to permit extension.
Then I can add new types of processing as follows:

<xsd:element name="rst" substitutionGroup="extended_process"/>

The XML Schema for the simple content version would replace the above
definition of ProcessChoiceType with the following:

<xsd:simpleType name="ProcessChoiceType">
<xsd:restriction base="xsd:token">
<xsd:enumeration value="abc"/>
<xsd:enumeration value="efg"/>
<xsd:enumeration value="xyz"/>
<xsd:restriction/>
</xsd:simpleType>

My understanding is the only way to extend the enumeration is to
define a new type, NewProcessChoiceType, using a union. However, I
don't know of any way to change the declaration of the <process>
element to use this new type.

So my initial analysis is that the empty content sub-elements are more
extensible. However, I've only been seriously studying XML Schema for
about a week. So I'm looking for guidance on these two choices. I
understand that a third alternative would be to use an attribute,
e.g., <process name="xyz"/>, but I don't think I can restrict the
domain of the name attribute using XML Schema, which defeats the whole
point of this discussion.

Thanks in advance for your opinions.

Mar 2 '07 #1
1 1671
It depends entirely on what you're trying to express.

Think about the semantics of the document. If the value is something
which really is a single value _conceptually_, but which may at some
point in the future want to carry additional sub-structure, make it an
element. If it's a simple text value and will never be more, make it
textual content, or -- if it's a characteristic of its containing
element -- possibly an attribute value (leaving the possibility open of
other attributes and/or content to be added later).

Look at other XML-based languages which solve similar problems and
decide which make the most sense for you.

And, as with any design skill you're still learning, resign yourself to
the fact that you're going to make some mistakes and have to do some
redesign until you develop a sense of style and the ability to think in
terms of larger patterns. Consider creating an initial version, working
with it for a while, and deciding whether you like the way it behaves
before you let it get cast in concrete.

Mar 2 '07 #2

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

Similar topics

5
by: John Dewbert | last post by:
*** post for FREE via your newsreader at post.newsfeed.com *** Hello, I have trouble passing a folder object (from a FileSystemObject) to a sub procedure. Consider the following code: ...
5
by: Colleyville Alan | last post by:
I have a sub that can do two different tasks based on the value of one variable. So I'd like to have two different buttons on the same form run this, but each one setting a flag so that the...
7
by: Doug | last post by:
An ASP.NET session cookie set on "www.mydomain.com" can not be accessed on "search.mydomain.com"; hence, a new session and cookie are being created on every sub-domain. This is occuring because...
12
by: Ron | last post by:
Greetings, I am trying to understand the rational for Raising Events instead of just calling a sub. Could someone explain the difference between the following 2 scenarios? Why would I want to...
4
by: dbuchanan | last post by:
Is the following behavior normal? Both the 'Protected sub' in the inherited form and the 'Private Shadows sub' in the derived form fires. My interpretation of MSDN help on the topic "Shadows"...
4
by: excelleinc.com | last post by:
Hello, I'm trying to put sub that's shared between all forms in my app in module so when I make change I just change it one time. This sub should execute and then invoke sub defaults() that's...
7
by: ILCSP | last post by:
Hi, I'm using VB.Net (2003) and I have a question. Does anyone knows how to call a procedure using a variable? The variable will be equal to the name of the procedure. for example, if I have...
5
by: Sharon | last post by:
Hi all. To prevent access to a sub system internal types, is it necessary to create the sub system in a different project, and use the internal access level? Or is there another way that will...
6
by: Greg Strong | last post by:
Hello All, Is is possible to use an ADO recordset to populate an unbound continuous Subform? I've done some Googling without much luck, so this maybe impossible, but let me try to explain...
6
by: Thom Little | last post by:
Using C# 3.5 I have a form that calls many other sub-forms. Typically there will be five forms open at the same time. If the main form is closed all the sub forms are also closed. Is there...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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?
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
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...

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.