Multi level embedding of xml files

Discussion in 'XML' started by campbell.shaun@gmail.com, Jan 27, 2005.

  1. Guest

    The application I am writing uses XML files for validation. I've been
    able to set up my xml files so that I can share validation for common
    fields using external entities. eg

    <?xml version="1.0"?>
    <!DOCTYPE foo [
    <!ENTITY ch1 SYSTEM "http://www.wiz.org/project/chap1.xml">
    <!ENTITY ch2 SYSTEM "http://www.wiz.org/project/chap2.xml">
    <!ENTITY ch3 SYSTEM "http://www.wiz.org/project/chap3.xml">

    ]>

    <foo>
    .... document instance here ...
    </foo>

    ....
    <foo>

    <BLIVET>&ch1;</BLIVET>

    <BLIVET>&ch2;</BLIVET>

    <BLIVET>&ch3;</BLIVET>

    </foo>

    This works fine but I would like to extend it so that I can include
    smaller chunks of xml in the included xml file. The problem I have is
    with the DOCTYPE declaration in the sub xml file which I need to
    include the sub-sub xml file as I don't want this included in my top
    level document.

    Is it possible to do what I want to do?

    Regards

    Shaun
    , Jan 27, 2005
    #1
    1. Advertising

  2. In article <>,
    <> wrote:

    >This works fine but I would like to extend it so that I can include
    >smaller chunks of xml in the included xml file. The problem I have is
    >with the DOCTYPE declaration in the sub xml file which I need to
    >include the sub-sub xml file as I don't want this included in my top
    >level document.
    >
    >Is it possible to do what I want to do?


    No, external entities are not complete XML files and can't have DTDs.
    You will have to define the entities in the top level file. You could
    modularize the top-level DTD using parameter entities in the same way
    as you have modularized the document itself: put the small chunk
    entity definitions in separate files like "chap1.dtd", and include
    them as external parameter entities in the top-level DTD like this:

    <!DOCTYPE foo [
    <!ENTITY ch1 SYSTEM "http://www.wiz.org/project/chap1.xml">
    <!ENTITY % ch1-ents SYSTEM "http://www.wiz.org/project/chap1.dtd">
    %ch1-ents;
    <!ENTITY ch2 SYSTEM "http://www.wiz.org/project/chap2.xml">
    <!ENTITY % ch2-ents SYSTEM "http://www.wiz.org/project/chap2.dtd">
    %ch2-ents;
    ....

    Each of chap1.dtd, chap2.dtd, ... could use more parameter entities to
    cut it into even smaller chunks.

    -- Richard
    Richard Tobin, Jan 27, 2005
    #2
    1. Advertising

  3. In article <ctb7r8$1emc$>,
    Richard Tobin <> wrote:

    I forgot to say:

    ><!ENTITY ch1 SYSTEM "http://www.wiz.org/project/chap1.xml">
    ><!ENTITY % ch1-ents SYSTEM "http://www.wiz.org/project/chap1.dtd">
    >%ch1-ents;


    You could put the definition of ch1 itself in chap1.dtd too.

    -- Richard
    Richard Tobin, Jan 27, 2005
    #3
    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. Mark Van Orman

    embedding xml in xml as non-xml :)

    Mark Van Orman, Sep 14, 2004, in forum: XML
    Replies:
    5
    Views:
    464
    Patrick TJ McPhee
    Sep 15, 2004
  2. Harri Pesonen

    Re: Embedding Python in multi-threaded app

    Harri Pesonen, Sep 4, 2003, in forum: Python
    Replies:
    0
    Views:
    820
    Harri Pesonen
    Sep 4, 2003
  3. Phil Frost
    Replies:
    3
    Views:
    509
    Donn Cave
    May 26, 2004
  4. Phil Frost
    Replies:
    1
    Views:
    304
    Ryan Paul
    May 27, 2004
  5. pabbu
    Replies:
    8
    Views:
    707
    Marc Boyer
    Nov 7, 2005
Loading...

Share This Page