Entity Definition in DTD

Discussion in 'XML' started by keith@melville.ws, Nov 28, 2006.

  1. Guest

    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
    , Nov 28, 2006
    #1
    1. Advertising

  2. Myron Turner Guest

    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

    wrote:
    > 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/
    Myron Turner, Nov 28, 2006
    #2
    1. Advertising

  3. In article <>,
    <> wrote:

    >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:
    >
    >> xmllint switch.xml

    >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
    --
    "Consideration shall be given to the need for as many as 32 characters
    in some alphabets" - X3.4, 1963.
    Richard Tobin, Nov 29, 2006
    #3
  4. Guest

    Richard Tobin wrote:
    > 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
    , Nov 29, 2006
    #4
  5. Myron Turner Guest

    It's instructive that xmllint lets you get away with an incomplete DTD.
    I always use Cooktop, and once you say you have a DTD, it wants
    it all.

    Cheers,

    Myron

    wrote:
    > Richard Tobin wrote:
    >> 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
    >



    --

    _____________________
    Myron Turner
    http://www.room535.org
    http://www.bstatzero.org
    http://www.mturner.org/XML_PullParser/
    Myron Turner, Nov 29, 2006
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Robert Lintner
    Replies:
    3
    Views:
    4,059
    Susanne Oberhauser
    Jul 25, 2003
  2. Samuel van Laere

    Entity Name or Entity Number?

    Samuel van Laere, Feb 24, 2007, in forum: HTML
    Replies:
    4
    Views:
    1,579
    Jukka K. Korpela
    Feb 24, 2007
  3. markla
    Replies:
    1
    Views:
    522
    Steven Cheng
    Oct 6, 2008
  4. Norm
    Replies:
    3
    Views:
    2,655
  5. ThatsIT.net.au

    Entity, problem with entity key

    ThatsIT.net.au, Sep 6, 2009, in forum: ASP .Net
    Replies:
    1
    Views:
    1,163
    ThatsIT.net.au
    Sep 7, 2009
Loading...

Share This Page