xi:include and global entity

Discussion in 'XML' started by Thomas Sommer, Sep 2, 2004.

  1. Hi,

    I know doing something like this

    <!DOCTYPE section PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
    "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd"
    [<!ENTITY test PUBLIC "BLA" "http://localhost/dummy/test">]>

    <section><title/>
    <programlisting><xi:include href="&test;" parse="text"
    xmlns:xi="http://www.w3.org/2001/XInclude"/></programlisting>
    </section>

    Will not work but maybe someone knows a workaround.
    Basically I want to insert my programlisting from a global entity.
    It works if I put the CDATA in front and at the end
    in the text file but I don't like that since it alters the file.

    Does anyone have a bright idea how to solve this issue?

    Thanks Thomas
    Thomas Sommer, Sep 2, 2004
    #1
    1. Advertising

  2. In article <>,
    Thomas Sommer <> wrote:
    >Basically I want to insert my programlisting from a global entity.


    Why do you need to put the contents of the file in an entity? Why
    not just do

    <xi:include href="http://localhost/dummy/test" parse="text"/>

    ?

    An ugly trick is to do something like this:

    <!ENTITY % test PUBLIC "BLA" "http://localhost/dummy/test">
    <!-- NB test is a parameter entity! -->
    <!ENTITY source "<![CDATA[%test;]]>">

    This won't work if your source contains ]]> of course.

    -- Richard
    Richard Tobin, Sep 2, 2004
    #2
    1. Advertising

  3. >
    > Why do you need to put the contents of the file in an entity? Why
    > not just do
    >
    > <xi:include href="http://localhost/dummy/test" parse="text"/>


    I know this works and would do the job if the catalog would remap this to
    "file:///home/dummy/docbook/some more dirs/test"
    I am about to set up my directory structure right now but I don't know if it
    might change later on. Using some global entities will save me from editing
    every single file (I hope). But maybe there is some better solution or this
    is totally unnecessary.

    > An ugly trick is to do something like this:
    >
    > <!ENTITY % test PUBLIC "BLA" "http://localhost/dummy/test">
    > <!-- NB test is a parameter entity! -->
    > <!ENTITY source "<![CDATA[%test;]]>">
    >

    I get:
    PEReferences forbidden in internal subset
    <!ENTITY source "<![CDATA[%test;]]>">

    While in the file I only have:
    Some Text
    Thomas Sommer, Sep 2, 2004
    #3
  4. In article <>,
    Thomas Sommer <> wrote:

    >> <!ENTITY % test PUBLIC "BLA" "http://localhost/dummy/test">
    >> <!-- NB test is a parameter entity! -->
    >> <!ENTITY source "<![CDATA[%test;]]>">


    >PEReferences forbidden in internal subset


    Yes you have to put it in an external DTD. You can't use parameter entities
    like that in the internal subset.

    -- Richard
    Richard Tobin, Sep 2, 2004
    #4
  5. > Yes you have to put it in an external DTD. You can't use parameter entities
    > like that in the internal subset.


    Ok, now the error is gone but I don't get the stuff from the file.
    It is loaded though. If I do
    <!ENTITY % test PUBLIC "BLA" "http://localhost/dummy/test">
    %test;

    I get complains about wrong syntax (of course).


    Ok I can use the source entity but there will be no text put into
    the xml-file even without the CDATA.

    Any further ideas

    Thanks Thomas
    Thomas Sommer, Sep 2, 2004
    #5
  6. In article <>,
    Thomas Sommer <> wrote:
    >Ok, now the error is gone but I don't get the stuff from the file.


    This works for me. It includes the contents of test.c:

    foo.xml:

    <!DOCTYPE foo SYSTEM "foo.dtd">
    <foo>
    &source;
    </foo>

    foo.dtd:

    <!ENTITY % test PUBLIC "BLA" "test.c">
    <!ENTITY source "<![CDATA[%test;]]>">

    But an XInclude solution is better, because ampersands in test.c still
    cause problems (I should have realised this before).

    -- Richard
    Richard Tobin, Sep 2, 2004
    #6
  7. It validates but I still don't get any output. Here the debug info:

    xmllint --debugent --valid foo.xml
    new input from file: foo.xml
    new input from file: foo.dtd
    Pushing input 1 :
    String decoding PE Reference: %test;]]>
    <?xml version="1.0"?>
    <!DOCTYPE foo SYSTEM "foo.dtd">
    <foo>
    &source;
    </foo>
    DOCUMENT
    No entities in internal subset
    Entities in external subset
    source : INTERNAL GENERAL,
    orig "<![CDATA[%test;]]>"
    content "<![CDATA[]]>"


    As you see the content is empty but maybe I am just too stupid to use
    xmllint.

    Thomas
    Thomas Sommer, Sep 2, 2004
    #7
    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. Samuel van Laere

    Entity Name or Entity Number?

    Samuel van Laere, Feb 24, 2007, in forum: HTML
    Replies:
    4
    Views:
    1,599
    Jukka K. Korpela
    Feb 24, 2007
  2. Andreas Bogenberger
    Replies:
    3
    Views:
    891
    Andreas Bogenberger
    Feb 22, 2008
  3. markla
    Replies:
    1
    Views:
    533
    Steven Cheng
    Oct 6, 2008
  4. Norm
    Replies:
    3
    Views:
    2,681
  5. ThatsIT.net.au

    Entity, problem with entity key

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

Share This Page