473,659 Members | 3,395 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problems with multiple multiple-level inclusion of DTDs

Hi all,

I have one DTD fragment, base.dtd, that contains a bunch of useful
element definitions (say an element named "base"), and two DTD
fragments, a.dtd and b.dtd, that each build on base.dtd and defines a
few more elements. I use an entity to include base.dtd in a.dtd and
b.dtd. For example, in a.dtd:

<!ENTITY % include.base SYSTEM "base.dtd">
%include.base
<!ELEMENT a (base+)>

In b.dtd:

<!ENTITY % include.base SYSTEM "base.dtd">
%include.base
<!ELEMENT b (#PCDATA|base)* >

In my XML documents, if I just want to use element a (or b), I simply
need to entity-include a.dtd, and that will automatically include
base.dtd, which is nice.

However, the trouble comes in when I entity-include both a.dtd and
b.dtd. The problem is that the element "base" will be included twice
(once via a.dtd->base.dtd and another time via b.dtd->base.dtd). Note
that multiple definitions of the "include.ba se" entity is fine (as per
XML standard), but multiple definitions of any element is disallowed.

I explored a few workarounds but couldn't find any clean solution (for
example, something that resembles C/C++'s #ifndef and #define). Any
suggestions will be appreciated!

--- Jun Y.
Jul 24 '08 #1
4 1871
ju*****@gmail.c om wrote:
Hi all,

I have one DTD fragment, base.dtd, that contains a bunch of useful
element definitions (say an element named "base"), and two DTD
fragments, a.dtd and b.dtd, that each build on base.dtd and defines a
few more elements. I use an entity to include base.dtd in a.dtd and
b.dtd. For example, in a.dtd:

<!ENTITY % include.base SYSTEM "base.dtd">
%include.base
<!ELEMENT a (base+)>

In b.dtd:

<!ENTITY % include.base SYSTEM "base.dtd">
%include.base
<!ELEMENT b (#PCDATA|base)* >

In my XML documents, if I just want to use element a (or b), I simply
need to entity-include a.dtd, and that will automatically include
base.dtd, which is nice.

However, the trouble comes in when I entity-include both a.dtd and
b.dtd. The problem is that the element "base" will be included twice
(once via a.dtd->base.dtd and another time via b.dtd->base.dtd). Note
that multiple definitions of the "include.ba se" entity is fine (as per
XML standard), but multiple definitions of any element is disallowed.
The technique is to use parameter-entity switches.

In a.dtd:

<!ENTITY % use.base.from.a "INCLUDE">
<![%use.base.from. a;[
%include.base;
<!ENTITY % use.base.from.b "IGNORE">
]]>

In b.dtd

<!ENTITY % use.base.from.b "INCLUDE">
<![%use.base.from. b;[
%include.base;
<!ENTITY % use.base.from.a "IGNORE">
]]>

This way, whichever one you invoke first will prevent the other one from
being activated.

Better would be to paramaterise a and b alone, and invoke your base in
your document type declaration with a PE switch to include whichever or
a and b (or both) that you require for the instance.

///Peter

Jul 26 '08 #2
On Jul 26, 4:40*pm, Peter Flynn <peter.n...@m.s ilmaril.iewrote :
>
The technique is to use parameter-entity switches.

In a.dtd:

<!ENTITY % use.base.from.a "INCLUDE">
<![%use.base.from. a;[
%include.base;
<!ENTITY % use.base.from.b "IGNORE">
]]>

In b.dtd

<!ENTITY % use.base.from.b "INCLUDE">
<![%use.base.from. b;[
%include.base;
<!ENTITY % use.base.from.a "IGNORE">
]]>

This way, whichever one you invoke first will prevent the other one from
being activated.
This would work, except that now a.dtd would need to know about b.dtd,
and vice versa, which is difficult to keep manage if there are many
potential includers of base.dtd...
Better would be to paramaterise a and b alone, and invoke your base in
your document type declaration with a PE switch to include whichever or
a and b (or both) that you require for the instance.
This is what I am doing for now, though users of a.dtd and b.dtd have
to manually manage inclusion.

Another possibility I thought of is to have an exclude-base-
includers.dtd file that sets all PE switches to false. This file would
be included by base.dtd. Each includer of base.dtd would set the its
own PE switch to true, and then include base.dtd. End users are hidden
from all this mess, but the downside of this approach is that the
exclude-base-includers.dtd file needs to be maintained.

--- Jun Y.
Jul 27 '08 #3
ju*****@gmail.c om wrote:
On Jul 26, 4:40 pm, Peter Flynn <peter.n...@m.s ilmaril.iewrote :
[snip]
>Better would be to paramaterise a and b alone, and invoke your base in
your document type declaration with a PE switch to include whichever or
a and b (or both) that you require for the instance.

This is what I am doing for now, though users of a.dtd and b.dtd have
to manually manage inclusion.

Another possibility I thought of is to have an exclude-base-
includers.dtd file that sets all PE switches to false. This file would
be included by base.dtd. Each includer of base.dtd would set the its
own PE switch to true, and then include base.dtd. End users are hidden
from all this mess, but the downside of this approach is that the
exclude-base-includers.dtd file needs to be maintained.
It's usually far easier to manage if you make base.dtd the external
entity referenced by the DOCTYPE Declaration, and let users add their
own selection of a, b, ... using a PE in the internal subset.

<!DOCTYPE whatever SYSTEM "/some/uri/for/base.dtd" [
<!ENTITY % a "INCLUDE">
]>

and do all your entity management and file inclusion in base.dtd, a.ent,
b.ent, or whatever.

///Peter
Jul 27 '08 #4
On Jul 27, 4:14*pm, Peter Flynn <peter.n...@m.s ilmaril.iewrote :
It's usually far easier to manage if you make base.dtd the external
entity referenced by the DOCTYPE Declaration, and let users add their
own selection of a, b, ... using a PE in the internal subset.

<!DOCTYPE whatever SYSTEM "/some/uri/for/base.dtd" [
<!ENTITY % a "INCLUDE">
]>

and do all your entity management and file inclusion in base.dtd, a.ent,
b.ent, or whatever.
Thanks! This is much cleaner than the exclude-base-includers.dtd
trick I thought of earlier.

--- Jun Y.
Jul 28 '08 #5

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

Similar topics

3
3081
by: Ramses van Pinxteren | last post by:
hello, I have a PHP/Javascript problem. If I want to make a multiple select like this one: $html .= "<td><select name='userid' onChange='changeuserinfo()' multiple size='10'>"; $html .= "<option value=''>Selecteer user</option>"; $html .= "<option value='1'>user 1</option>"; $html .= "<option value='2'>user 2</option>";
13
3279
by: John Perks and Sarah Mount | last post by:
Trying to create the "lopsided diamond" inheritance below: >>> class B(object):pass >>> class D1(B):pass >>> class D2(D1):pass >>> class D(D1, D2):pass Traceback (most recent call last): File "<stdin>", line 1, in ? TypeError: Error when calling the metaclass bases Cannot create a consistent method resolution
9
2582
by: Daniel Moree | last post by:
I'm using MS VC++ 6.0 I'm working on a big project. I've currently have several files for this project. Here's the problem. I have one header file phead.h I have two code files main.cpp and gameloop.cpp phead.h has all my core declarations in it like my main globals. main.cpp has all my window initilization functions and my winproc loop.
3
2840
by: headware | last post by:
I have an issue that I've been encountering in an ASP application I'm working on. Most of the application is written in ASP, but there is one page written in ASP.NET. The ASP.NET page needs to have access to the ASP Session data to run correctly. In order to achieve this I create my own HTTP request for a certain ASP page with the name of Session variable that I want is stored in the query string of the request. The requested ASP page...
2
2319
by: Ellen Graves | last post by:
I am having a lot of problems with DB2 8.3.1 on RH Linux AS2.1. Installing and running stored procedures is problematic. Stored procedures I have used for years on V7 on WinNT are now failing multiple times/day. Data that exists in the db is not returned with a select *, but is returned when a where clause with a primary key value is specified. There are other problems, including the db crashing in the middle of a simple query.
1
4837
by: mary | last post by:
I am developing an Access db which will be used by multiple users. My questions are: Does MS Access have problems with multiple users accessing the db at once? If yes, what is your solution to this problem? I was informed that Access is not a good application for multiple users accessing it at once.
2
4171
by: JMCN | last post by:
i am running into problems with is the recordset. i have exactly 104 records. when i tested the code, the end result was multiple records for the same loan(ET LN Shortname). where did i go wrong? so i tried a couple of different do... loop statements and ended up getting the same results, that is having multiple records of the same loan(ET LN Shortname). so if anyone has any suggestions, it would be appreciated :) thanks in advance and...
1
1919
by: Johan | last post by:
If a user happens to open multiple instances of her frontend, what kind of problems can occur? For example, one user reported that she was able to, once or twice, bypass the evaluation procedures that check a new record before it's allowed into the database. She said that this happened on a day when her computer behaved strangely in general. We have not been able to repeat/reconstruct the error, and I wonder if the explanation can be...
2
3169
by: Brian | last post by:
NOTE ALSO POSTED IN microsoft.public.dotnet.framework.aspnet.buildingcontrols I have solved most of my Server Control Collection property issues. I wrote an HTML page that describes all of the problems that I have encountered to date and the solutions (if any) that I found. http://users.adelphia.net/~brianpclab/ServerControlCollectionIssues.htm This page also has all of the source code in a compressed file that you are free to download...
7
7131
by: samayjain | last post by:
Dear , Please let me know the correct answer for the following 1.Which three statements about subqueries are true? (Choose three.) A. A single row subquery can retrieve only one column and one row. B. A single row subquery can retrieve only one row but many columns. C. A multiple row subquery can retrieve multiple rows and multiple columns.
0
8428
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8851
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8748
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
8531
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
8628
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
7359
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
6181
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
4175
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
1739
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.