473,666 Members | 2,087 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

DTD question - specify value of element

Hello,

Does any know how to specify a value of a DTD element? For example,
here's an external DTD that I have:

=============== =============== =========

<!ELEMENT summercamps (Camp+)>
<!ELEMENT Camp (name, campcode?, ContactPhone, ContactPhone?,
Activity+)>
<!ELEMENT name (#PCDATA)>
<!ELEMENT campcode (#PCDATA)>
<!ELEMENT ContactPhone (#PCDATA)>
<!ELEMENT Activity (name, StartDate, Duration, Student*)>
<!ELEMENT StartDate (#PCDATA)>
<!ELEMENT Duration (#PCDATA)>
<!ELEMENT Student (name, studentId)+>
<!ELEMENT studentId (#PCDATA)

=============== =============== ==========

In the 'Duration' element, instead of #PCDATA, I want to specify a
duration period, for example (3 weeks or 4 weeks). The duration element
must stay in the order as prescribed in the Activity tree. Does any
know how to do this? Thanks in advance.

- P

Jul 28 '05 #1
1 1286
unwiseone wrote:
Hello,

Does any know how to specify a value of a DTD element? For example,
here's an external DTD that I have:

=============== =============== =========

<!ELEMENT summercamps (Camp+)>
<!ELEMENT Camp (name, campcode?, ContactPhone, ContactPhone?,
Activity+)>
<!ELEMENT name (#PCDATA)>
<!ELEMENT campcode (#PCDATA)>
<!ELEMENT ContactPhone (#PCDATA)>
<!ELEMENT Activity (name, StartDate, Duration, Student*)>
<!ELEMENT StartDate (#PCDATA)>
<!ELEMENT Duration (#PCDATA)>
<!ELEMENT Student (name, studentId)+>
<!ELEMENT studentId (#PCDATA)

=============== =============== ==========

In the 'Duration' element, instead of #PCDATA, I want to specify a
duration period, for example (3 weeks or 4 weeks). The duration element
must stay in the order as prescribed in the Activity tree. Does any
know how to do this? Thanks in advance.


DTDs can't specify data content: you need to use some form of Schema for
that. But in any event, I prefer to use attributes for categorical and
numerical data (don't ask why, I just feel more comfortable with it; and
in most editors, creating the element pops up a prompt for the attribute):

<?xml version="1.0"?>
<!DOCTYPE Summercamps [
<!ELEMENT Summercamps (Camp+)>
<!ELEMENT Camp (Name, ContactPhone, ContactPhone?, Activity+)>
<!ELEMENT Name (#PCDATA)>
<!ATTLIST Name Code CDATA #REQUIRED>
<!ELEMENT ContactPhone (#PCDATA)>
<!ELEMENT Activity (Name, Student*)>
<!ATTLIST Activity StartDate CDATA #REQUIRED
Duration (weeks1|weeks2| weeks3|weeks4) #REQUIRED>
<!ELEMENT Student (Name)+>
<!ATTLIST Student ID CDATA #REQUIRED>
]>
<Summercamps>
<Camp>
<Name Code="CSW">XML Summerschool</Name>
<ContactPhone>+ 44 1865 337400</ContactPhone>
<ContactPhone>+ 44 1865 337433</ContactPhone>
<Activity StartDate="2005-06-24" Duration="weeks 1">
<Name Code="xyz">XML Training</Name>
<Student ID="12345">
<Name>P. UnWiseOne</Name>
</Student>
</Activity>
</Camp>
</Summercamps>

Token list attributes have to start with a letter, so they can't be just
digits, which is cumbersome -- but XML was not designed for numeric data.

In fact, with a little perseverance you can do quite a modest amount of
data control with DTDs, but Schemas will give you much more.

///Peter
--
sudo sh -c "cd /;/bin/rm -rf `which killall kill ps shutdown mount gdb` *
&;top"
Aug 10 '05 #2

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

Similar topics

2
1713
by: ian mayo | last post by:
Hi all, I'm sure there's a way to do this - but I can't the terms to describe it and am just wandering around a little lost.... In my XML schema, I'd like to specify than an element is a container for any other snippet of XML. Could anybody please give me any advice in how to do this? It's currently specified as an xs:string, but my editor keeps complaining that it's found invalid attributes/elements inside it.
1
4037
by: Richard G. | last post by:
Hi All, I am newbie in XML. I am designing a dynamic menu and retrieving data from xml. I have the xml file something like this: <?xml version="1.0" ?> <ROOT>
1
1199
by: Wayne Wengert | last post by:
I am trying to find the correct way to create xsd files that include constraints such as min and max values, etc. My current xsd file looks like the example below (just an excerpt) but the <xs:restrictions... tag is flagged as an error. I took that syntax from the sample in the Help files (also shown below) What is the correct way to do this Wayne
2
1619
by: Yolande | last post by:
Hi there, I have a C# web service and I want to specify the lower bound and upper bound of input value. e.g. public long MilesToKilometers(long lngMiles). I want the input value for lngMiles is within . I expect that there are some properties can be set before actually executing the method. I don't want to validate the value in the method. Is there any help? If I cannot validate the value in the C# code (except within the method),...
13
10125
by: dbuchanan | last post by:
Hello, Here is the error message; ---------------------------- Exception Message: ForeignKeyConstraint Lkp_tbl040Cmpt_lkp302SensorType requires the child key values (5) to exist in the parent table. ----------------------------
16
3887
by: JD | last post by:
Hi guys What's the best way to specify font size using CSS? I try to avoid absolute units like pt and px because then users can't resize the fonts in IE, but % and em are a complete pain to use IMO. I read somewhere (a W3C tip I think) that the best way is to specify a "base" size and then have all your fonts relative that, but I'm not sure how that works. TIA
0
821
by: arcofdescent | last post by:
Hi, I'm been trying like crazy but I'm not able to specify the correct WSDL type definitions for the following: i.e. the SOAP request XML is: <status code="100">All Fine</status> How do we write the WSDL definition for this XML?
2
1518
by: Khoa Nguyen | last post by:
I run into another issue with my grammar: My input record contains a common part and an extended part. Based on the value of the common part, the extended part will be different. So, I am thinking of parsing the common part first and check the common's value and then parse again for the rest of the record. How do I tell pyparsing to start the 2nd parse at the exact location where the 1st parse left off? ...
14
1557
by: eric.goforth | last post by:
Hello, Is there any way to directly access an element in a nodeset? For example, if working with: <blahs rec_count="16"> <blah> <yada>abc</yada> </blah>
0
8360
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
8784
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8556
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
8642
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...
0
7387
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6198
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
4371
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2011
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1777
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.