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

particular costraints in mixed contents

JU
Hello,
I am pretty new in XML and I'm studying the DTD definition. I cannot
solve a problem, or better, I cannot define what I want in my DTD file.
What I would like to do is that something like
<el>text <child/> text</el>
is accepted but not
<el>text <child/> text<child/></el>

I know that <!ELEMENT el (#PCDATA|child)*> declares the element el as a
mixed content of PCDATA and child but what I want to define is that the
element child occurs exactly once and not more. Instead of PCDATA can
occur either before, after or never. I tried with
(#PCDATA,child+,#PCDATA) but it's not working. Do you know if what I
want is possible? Thanks a lot in advance, and sorry if it's a silly
question. bye!

Jun 27 '06 #1
2 980


JU wrote:

I know that <!ELEMENT el (#PCDATA|child)*> declares the element el as a
mixed content of PCDATA and child but what I want to define is that the
element child occurs exactly once and not more. Instead of PCDATA can
occur either before, after or never. I tried with
(#PCDATA,child+,#PCDATA) but it's not working. Do you know if what I
want is possible?


An XML DTD can't do that. An XML XSD schema however could:

<xs:element name="el">
<xs:complexType mixed="true">
<xs:sequence>
<xs:element name="child" />
</xs:sequence>
</xs:complexType>
</xs:element>

--

Martin Honnen
http://JavaScript.FAQTs.com/
Jun 27 '06 #2
JU wrote:
Hello,
I am pretty new in XML and I'm studying the DTD definition. I cannot
solve a problem, or better, I cannot define what I want in my DTD file.
What I would like to do is that something like
<el>text <child/text</el>
is accepted but not
<el>text <child/text<child/></el>

I know that <!ELEMENT el (#PCDATA|child)*declares the element el as a
mixed content of PCDATA and child but what I want to define is that the
element child occurs exactly once and not more. Instead of PCDATA can
occur either before, after or never. I tried with
(#PCDATA,child+,#PCDATA) but it's not working. Do you know if what I
want is possible?
You can't declare that in XML using a DTD (it would be possible in SGML,
though, but you don't want to go there). If it's essential to use a DTD,
you could use subelements of el, for example

<!ELEMENT el (text,child,text)>
....
<el><text>stuff</text><child/><text>more stuff</text></el>

or use a W3C Schema instead as Martin suggests.

///Peter
Jul 3 '06 #3

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

Similar topics

15
by: Bill Cohagan | last post by:
I'm trying to generate class definitions from an XSD that contains something like: <xs:complexType name="foo" mixed="true"> <xs:choice minOccurs = "0" maxOccurs="unbounded"> <xs:element name =...
5
by: Adam McKee | last post by:
We are using Visual Studio.NET 2003 in our project with .NET framework 1.1. One of our libraries is a mixed-mode dll assembly consisting of one managed C++ library, and several unmanaged C++...
4
by: Evan Camilleri | last post by:
What is the fastest way to get the 'hash' (or CRC32 or whatever) of the contents of an object i don't care what's inside, I just want the 'hash' of its contents (not to mixed with...
5
by: Evan Camilleri | last post by:
What is the fastest way to get the 'hash' (or CRC32 or whatever) of the contents of an object i don't care what's inside, I just want the 'hash' of its contents (not to mixed with...
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: 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
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
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,...

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.