Entity declaration in DTD

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

  1. Hi,

    I want to use formulas in docbook and use the following for
    inlineequations.

    Text
    <inlineequation><inlinemediaobject><imageobject>
    <imagedata fileref="1.png"/></imageobject></inlinemediaobject>
    <alt role="tex">\vec{A}</alt></inlineequation>
    Text

    Now this is hard to read unlike in TEX: Text &\vec{A}$ Text.
    So I thought I would define some entities in my DTD that would
    replace everything except the data I have type so it would look
    something like this:

    Text &e1;1.png&e2;\vec{A}&e3; Text

    Now this does not work and even a simple thing like

    <!ENTITY pb "<para>">
    <!ENTITY pe "</para>">

    Use like
    &pb;TEXT&pe;

    gives:

    Entity: line 1: parser error : Premature end of data in tag para line 1
    <para>

    Looks like it wants to parse the entity itself. Would there be a way to
    avoid this.

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

  2. In article <>,
    Thomas Sommer <> wrote:

    ><!ENTITY pb "<para>">
    ><!ENTITY pe "</para>">


    Unfortunately entities have to be balanced with respect to elements,
    so you can't do this sort of thing.

    If you're doing a lot of this, you could define your own XML syntax
    and a stylesheet that converts it to the docbook format. For example,
    you could use

    <eqn image="1.png" tex="\vec{A}"/>

    and have the stylesheet transform that to

    ><inlineequation><inlinemediaobject><imageobject>
    > <imagedata fileref="1.png"/></imageobject></inlinemediaobject>
    > <alt role="tex">\vec{A}</alt></inlineequation>


    with a template like

    <xsl:template match="eqn">
    <inlineequation>
    <inlinemediaobject>
    <imageobject>
    <imagedata fileref="{@image}"/>
    </imageobject>
    </inlinemediaobject>
    <alt role="tex"><xsl:value-of select="@tex"/></alt>
    </inlineequation>
    </xsl:template>

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

  3. I just got the same idea but I was puzzled that one can put this
    in the stylesheet. And if I do that I only get the value of the
    "tex" entry. Not more not less.
    The command line I use:

    xsltproc -o test.tex ~/xml/tex.xsl doc.xml

    The beginning of tex.xsl looks like this:

    <?xml version='1.0' encoding="ISO-Latin-1"?>
    <xsl:stylesheet
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
    <xsl:import href="http://db2latex.sourceforge.net/xsl/docbook.xsl"/>

    <xsl:template match="eqn">
    <equation>
    <mediaobject>
    <imageobject>
    <imagedata fileref="{@image}"/></imageobject>
    </mediaobject>
    <alt role="tex"><xsl:value-of select="@tex"/></alt>
    </equation>
    </xsl:template>

    I am not sure but in my understanding the
    stylefile can only convert my xml-file into some other format. So the
    "replacement" of the eqn should happen before using the style. Thus I
    think one should do something like

    <xsl:template match="eqn">
    <xsl:text>\begin{equation}</xsl:text>
    <alt role="tex"><xsl:value-of select="@tex"/></alt>
    <xsl:text>\end{equation}</xsl:text>
    </equation>
    </xsl:template>

    And adapt the style sheet for the html-output the same way. But this is not
    very handy.

    Thomas
     
    Thomas Sommer, Sep 8, 2004
    #3
  4. In article <>,
    Thomas Sommer <> wrote:

    >The beginning of tex.xsl looks like this:
    >
    ><?xml version='1.0' encoding="ISO-Latin-1"?>
    ><xsl:stylesheet
    > xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
    > <xsl:import href="http://db2latex.sourceforge.net/xsl/docbook.xsl"/>
    >
    ><xsl:template match="eqn">


    I wasn't suggesting that you combine it with the docbook stylesheet,
    but that you have a completely separate stylesheet that you run
    beforehand. Its output would be vanilla docbook with <equation>
    elements and so on. The you would run the docbook stylesheet on that.

    As well as the template I posted, the stylesheet would have to have
    an identity template to pass the rest of the document through
    unchanged:

    <xsl:template match="node()|@*">
    <xsl:copy>
    <xsl:apply-templates select="node()|@*"/>
    </xsl:copy>
    </xsl:template>

    -- Richard
     
    Richard Tobin, Sep 8, 2004
    #4
    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,120
    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,677
    Jukka K. Korpela
    Feb 24, 2007
  3. markla
    Replies:
    1
    Views:
    561
    Steven Cheng
    Oct 6, 2008
  4. Norm
    Replies:
    3
    Views:
    2,771
  5. ThatsIT.net.au

    Entity, problem with entity key

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

Share This Page