473,387 Members | 1,542 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.

More flexible DTD solution needed

Hello!

I'm relatively new to writing DTDs, so be gentle with me :)

I'm writing a DTD to validate XML documents that script my product which
managed XHTML.

I want to use the DTD to enforce basic, high level structure but I don't
want to account for every single type of element that could be in the
script document.

For instance, I want to allow this:

<script>
<add-page>
<name>testPage</name>
<content>
ALL SORTS OF XHTML CONTENT GOES HERE
</content>
</add-page>
</script>

In my DTD I specify the rules for the script, add-page, name, and
content elements. However, I want to allow all sorts of markup in the
content element without having to account for it in the DTD.

In other words, if the user supplies:

<script>
<add-page>
<name>testPage</name>
<content>
<b>Hi!</b>
</content>
</add-page>
</script>

Then I get an error when validating because 'b' was not defined as an
element.

Any ideas, or is this not possible using DTD ?

thanks,
Collin
Jul 20 '05 #1
4 1316
Collin VanDyck wrote:
Hello!

I'm relatively new to writing DTDs, so be gentle with me :)

I'm writing a DTD to validate XML documents that script my product which
managed XHTML.

I want to use the DTD to enforce basic, high level structure but I don't
want to account for every single type of element that could be in the
script document.
You can't. Validation means accounting for every single element.
For instance, I want to allow this:

<script>
<add-page>
<name>testPage</name>
<content>
ALL SORTS OF XHTML CONTENT GOES HERE
</content>
</add-page>
</script>
That's different. Depending on what you really mean, you could either

a) write a DTD which allowed XHTML mixed content, equivalent to the
content model for P, for example

b) write a DTD which allowed any arbitrary mix of XHTML element types
(so it would never actually be valid XHTML in there, just a jumble.

(a) is easy. (b) is not so easy, because you still have to declare the
element types and provide them with content models.
Any ideas, or is this not possible using DTD ?


You either want valid XML or you don't. If you want it valid, it has to
conform to a DTD or Schema, so you have to write one which it can be
validated against. If you don't want to do that, you can't have valid
XML, just well-formed XML. Your call.

///Peter
--
"The cat in the box is both a wave and a particle"
-- Terry Pratchett, introducing quantum physics in _The Authentic Cat_
Jul 20 '05 #2
In article <Qr******************@news.easynews.com>,
Collin VanDyck <co*********@gluedtomyseat.doht.com> wrote:
Any ideas, or is this not possible using DTD ?


Right, it's not possible.

It can be done with XML Schemas though.

-- Richard
Jul 20 '05 #3

"Richard Tobin" <ri*****@cogsci.ed.ac.uk> wrote in message
news:ct***********@pc-news.cogsci.ed.ac.uk...
In article <Qr******************@news.easynews.com>,
Collin VanDyck <co*********@gluedtomyseat.doht.com> wrote:
Any ideas, or is this not possible using DTD ?


Right, it's not possible.

It can be done with XML Schemas though.

-- Richard


Richard, can you explain this point with more details ?
Please... ;-)

Tommaso
Jul 20 '05 #4
In article <41*********************@news.tiscali.it>,
Tommaso Torti <to*******@NOSPAMquinary.com> wrote:
It can be done with XML Schemas though.
Richard, can you explain this point with more details ?


XML Schemas allow you to use a "wildcard" that matches any element,
and you can specify whether the subtree rooted at that element should
be validated.

For an introduction to XML Schemas see

http://www.w3.org/TR/xmlschema-0/

-- Richard
Jul 20 '05 #5

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

Similar topics

303
by: mike420 | last post by:
In the context of LATEX, some Pythonista asked what the big successes of Lisp were. I think there were at least three *big* successes. a. orbitz.com web site uses Lisp for algorithms, etc. b....
21
by: Rabbit63 | last post by:
Hi: I want to show a set of records in the database table on the clicnt browser. I have two ways to do this (writen in JScript): 1.The first way is: <% var sql = "select firstname from...
354
by: Montrose... | last post by:
After working in c# for a year, the only conclusion I can come to is that I wish I knew c. All I need is Linux, the gnu c compiler and I can do anything. Web services are just open sockets...
11
by: Jonan | last post by:
Hello, For several reasons I want to replace the built-in memory management with some custom built. The mem management itlsef is not subject to my question - it's ok to the point that I have...
5
by: mikegw | last post by:
Hello all. I am currently using an implementation of sysV shared memory. The entire shared memory is allocated is one continuous block of which I get the pointer to the head, everything should...
8
by: ulyses | last post by:
I'm trying to put pointer to flexible array of structures in other structure. I want to have pointer to array of pixels in screen structure. Here is mine code, but I think it isn't quite all right:...
5
by: Hexman | last post by:
I've come up with an error which the solution eludes me. I get the error: >An unhandled exception of type 'System.Runtime.InteropServices.COMException' occurred in HRTest.exe > >Additional...
0
by: robert | last post by:
As more and more python packages are starting to use the bloomy (Java-ish) 'logging' module in a mood of responsibility and as I am not overly happy with the current "thickener" style of usage, I...
7
by: Sky | last post by:
I have been looking for a more powerful version of GetType(string) that will find the Type no matter what, and will work even if only supplied "{TypeName}", not the full "{TypeName},{AssemblyName}"...
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: 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
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
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.