Entity Definition in DTD

K

keith

Hi, I'm new to DTDs and trying to get a DTD file to define an entity
for me, but the entity never gets defined. Looking for some insight.
Here are the files I'm working with:

-----equipment.dtd-----
<?xml version="1.0"?>
<!DOCTYPE equipment [
<!ENTITY ethernetport SYSTEM "port-ethernet.subt">
]>

-----port-ethernet.subt------
<property name="Logic Type" value="Ethernet"/>
<property name="Physical Type" value="RJ-45"/>
<property name="Hostname" value="" status="writable"/>
<property name="IP Address" value="192.168.0.0" status="writable"/>
<property name="Subnet Mask" value="255.255.255.0" status="writable"/>

-----switch.xml-------
<?xml version="1.0"?>
<!DOCTYPE equipment SYSTEM "equipment.dtd">
<equipment>
<property name="Manufacturer" value="NETWERKS"/>
<property name="Model" value="400XRS LTD"/>
<ports>
<port> &ethernetport;
<property name="Port Name" value="Ethernet1"/>
</port>
<port> &ethernetport;
<property name="Port Name" value="Ethernet2"/>
</port>
<port> &ethernetport;
<property name="Port Name" value="Ethernet3"/>
</port>
<port> &ethernetport;
<property name="Port Name" value="Ethernet4"/>
</port>
</ports>
</equipment>

When I xmllint switch.xml, xmllint complains:
xmllint switch.xml
switch.xml:11: error: Entity 'ethernetport' not defined
<port> &ethernetport;

Any ideas what I'm doing wrong?

Thanks in advance.

Keith
 
M

Myron Turner

There are a number of problesm. Two XML declatations:
<?xml version="1.0"?>
An d Two Doctypes, and no dtd definition. This will work:

<!DOCTYPE equipment [
<!ELEMENT equipment (property|ports)+>
<!ELEMENT property EMPTY>
<!ATTLIST property name CDATA #REQUIRED
value CDATA #REQUIRED
status CDATA #IMPLIED
>
<!ELEMENT ports (port)+ >
<!ELEMENT port (property)+ >
<!ENTITY ethernetport SYSTEM "port_ethernet.xml">
]>
<equipment>
<property name="Manufacturer" value="NETWERKS"/>
<property name="Model" value="400XRS LTD"/>
<ports>
<port>&ethernetport;
<property name="Port Name" value="Ethernet1"/>
</port>
<port> &ethernetport;
<property name="Port Name" value="Ethernet2"/>
</port>
<port> &ethernetport;
<property name="Port Name" value="Ethernet3"/>
</port>
<port> &ethernetport;
<property name="Port Name" value="Ethernet4"/>
</port>
</ports>
</equipment>

Cheers,

Myron Turner

Hi, I'm new to DTDs and trying to get a DTD file to define an entity
for me, but the entity never gets defined. Looking for some insight.
Here are the files I'm working with:

-----equipment.dtd-----
<?xml version="1.0"?>
<!DOCTYPE equipment [
<!ENTITY ethernetport SYSTEM "port-ethernet.subt">
]>

-----port-ethernet.subt------
<property name="Logic Type" value="Ethernet"/>
<property name="Physical Type" value="RJ-45"/>
<property name="Hostname" value="" status="writable"/>
<property name="IP Address" value="192.168.0.0" status="writable"/>
<property name="Subnet Mask" value="255.255.255.0" status="writable"/>

-----switch.xml-------
<?xml version="1.0"?>
<!DOCTYPE equipment SYSTEM "equipment.dtd">
<equipment>
<property name="Manufacturer" value="NETWERKS"/>
<property name="Model" value="400XRS LTD"/>
<ports>
<port> &ethernetport;
<property name="Port Name" value="Ethernet1"/>
</port>
<port> &ethernetport;
<property name="Port Name" value="Ethernet2"/>
</port>
<port> &ethernetport;
<property name="Port Name" value="Ethernet3"/>
</port>
<port> &ethernetport;
<property name="Port Name" value="Ethernet4"/>
</port>
</ports>
</equipment>

When I xmllint switch.xml, xmllint complains:
xmllint switch.xml
switch.xml:11: error: Entity 'ethernetport' not defined
<port> &ethernetport;

Any ideas what I'm doing wrong?

Thanks in advance.

Keith


--

_____________________
Myron Turner
http://www.room535.org
http://www.bstatzero.org
http://www.mturner.org/XML_PullParser/
 
R

Richard Tobin

Hi, I'm new to DTDs and trying to get a DTD file to define an entity
for me, but the entity never gets defined. Looking for some insight.
Here are the files I'm working with:
-----equipment.dtd-----
<?xml version="1.0"?>
<!DOCTYPE equipment [
<!ENTITY ethernetport SYSTEM "port-ethernet.subt">
]>

You don't put <!DOCTYPE name [ ... ]> around the contents of a
DTD file. You only do that in the document itself, and only use
the square-bracketed part if you are including declarations
there (known as an internal subset).

Also (and this is just an annoying misfeature) if you have an
<?xml ...?> declaration in anything but the document itself, it
must include an encoding declaration, e.g. encoding="utf-8".
If you don't need to declare the encoding, just leave out the
whole declaration.

So if you change equipment.dtd to just contain

<!ENTITY ethernetport SYSTEM "port-ethernet.subt">

all will be well.
When I xmllint switch.xml, xmllint complains:

switch.xml:11: error: Entity 'ethernetport' not defined
<port> &ethernetport;

Ah, well, in fact xmllint was not reading the external DTD at all.
You need --loaddtd and --noent to get the DTD read and entities
expanded.

-- Richard
 
K

keith

Richard said:
So if you change equipment.dtd to just contain

<!ENTITY ethernetport SYSTEM "port-ethernet.subt">

all will be well.
Ah, well, in fact xmllint was not reading the external DTD at all.
You need --loaddtd and --noent to get the DTD read and entities
expanded.

Thanks. This did the trick.
Keith
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top