Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > Entity declaration in DTD

Reply
Thread Tools

Entity declaration in DTD

 
 
Thomas Sommer
Guest
Posts: n/a
 
      09-08-2004
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
 
Reply With Quote
 
 
 
 
Richard Tobin
Guest
Posts: n/a
 
      09-08-2004
In article <(E-Mail Removed)>,
Thomas Sommer <(E-Mail Removed)> 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
 
Reply With Quote
 
 
 
 
Thomas Sommer
Guest
Posts: n/a
 
      09-08-2004
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
xmlnssl="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
 
Reply With Quote
 
Richard Tobin
Guest
Posts: n/a
 
      09-08-2004
In article <(E-Mail Removed)>,
Thomas Sommer <(E-Mail Removed)> wrote:

>The beginning of tex.xsl looks like this:
>
><?xml version='1.0' encoding="ISO-Latin-1"?>
><xsl:stylesheet
> xmlnssl="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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Entity, problem with entity key ThatsIT.net.au ASP .Net 1 09-07-2009 02:20 AM
Entity Framework - Reassigning child entity's parent Norm ASP .Net 3 07-06-2009 07:28 PM
How to relate a SQL based entity with an Object based entity in Entity Framework markla ASP .Net 1 10-06-2008 09:42 AM
Entity Name or Entity Number? Samuel van Laere HTML 4 02-24-2007 10:11 PM
XML Schema <-> DTD ? equivalent to external ENTITY Robert Lintner XML 3 07-25-2003 11:24 AM



Advertisments