Entity declaration in DTD

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Thomas Sommer

    #1

    Entity declaration in DTD

    Hi,

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

    Text
    <inlineequation ><inlinemediaob ject><imageobje ct>
    <imagedata fileref="1.png"/></imageobject></inlinemediaobje ct>
    <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;\v ec{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
  • Richard Tobin

    #2
    Re: Entity declaration in DTD

    In article <pan.2004.09.08 .17.30.54.93853 1@gmx.de>,
    Thomas Sommer <mawa15@gmx.d e> wrote:
    [color=blue]
    ><!ENTITY pb "<para>">
    ><!ENTITY pe "</para>">[/color]

    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
    [color=blue]
    ><inlineequatio n><inlinemediao bject><imageobj ect>
    > <imagedata fileref="1.png"/></imageobject></inlinemediaobje ct>
    > <alt role="tex">\vec {A}</alt></inlineequation>[/color]

    with a template like

    <xsl:template match="eqn">
    <inlineequation >
    <inlinemediaobj ect>
    <imageobject>
    <imagedata fileref="{@imag e}"/>
    </imageobject>
    </inlinemediaobje ct>
    <alt role="tex"><xsl :value-of select="@tex"/></alt>
    </inlineequation>
    </xsl:template>

    -- Richard

    Comment

    • Thomas Sommer

      #3
      Re: Entity declaration in DTD

      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:styleshe et
      xmlns:xsl="http ://www.w3.org/1999/XSL/Transform" version="1.0">
      <xsl:import href="http://db2latex.source forge.net/xsl/docbook.xsl"/>

      <xsl:template match="eqn">
      <equation>
      <mediaobject>
      <imageobject>
      <imagedata fileref="{@imag e}"/></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
      "replacemen t" of the eqn should happen before using the style. Thus I
      think one should do something like

      <xsl:template match="eqn">
      <xsl:text>\begi n{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

      Comment

      • Richard Tobin

        #4
        Re: Entity declaration in DTD

        In article <pan.2004.09.08 .22.13.54.79747 3@gmx.de>,
        Thomas Sommer <mawa15@gmx.d e> wrote:
        [color=blue]
        >The beginning of tex.xsl looks like this:
        >
        ><?xml version='1.0' encoding="ISO-Latin-1"?>
        ><xsl:styleshee t
        > xmlns:xsl="http ://www.w3.org/1999/XSL/Transform" version="1.0">
        > <xsl:import href="http://db2latex.source forge.net/xsl/docbook.xsl"/>
        >
        ><xsl:templat e match="eqn">[/color]

        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

        Comment

        Working...