473,387 Members | 1,693 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Entity declaration in DTD

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
Jul 20 '05 #1
3 1929
In article <pa****************************@gmx.de>,
Thomas Sommer <ma****@gmx.de> 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
Jul 20 '05 #2
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
Jul 20 '05 #3
In article <pa****************************@gmx.de>,
Thomas Sommer <ma****@gmx.de> 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
Jul 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Ronald Fischer | last post by:
Could someone explain to me what is the difference between <!ENTITY % Foo 'Bar' > and <!ENTITY Foo 'Bar' > From my understanding, the "macro" Foo has to be referenced in the first case...
6
by: Vincent Lefevre | last post by:
I would like to know if the base URI considered to resolve an unparsed entity defined by a relative URI should be the URI before or after its rewriting due to a possible catalog. Let's take an...
11
by: Douglas Reith | last post by:
Hi There, Can someone please tell me why the XML spec states that an attribute value with an external entity is forbidden? Or point me to the appropriate document? Or better still, perhaps you...
4
by: Per | last post by:
Hi, I'm struggling with the DocBook XML DTD, which can be found at http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd. But this DTD seems to somehow include some other documents. E.g.: ...
6
by: Phil Jarvis | last post by:
I have an XML Schema with regular expressions. e.g. <xsd:pattern value="{1}*"/> I have other patterns in the same schema document which share regular expression substructure, like the string...
4
by: Ian Rutgers | last post by:
If I am using an DTD in an xml file I know to declare an entity I would enter; <!DOCTYPE letter > How and where would I declare the entity? (Sorry for the silly question) Thank you,
1
by: Razvan | last post by:
Hi What is the difference between an internal and an external entity ? The first one is defined in the internal subset (not in a separate DTD file, but in the XML file itself - in...
3
by: bgeci | last post by:
I have problem with Entity definition. ____________________________________________ my file "test.xml" ---- <?xml version="1.0" ?> <!DOCTYPE message > <message>&Ep;</message> ---- IE6 Error...
6
by: Tuomas Rannikko | last post by:
Hello, I'm currently writing a XML processor for the fun of it. There is something I don't understand in the spec though. I'm obviously missing something important. The spec states that both...
4
by: keith | last post by:
Hi, I'm new to DTDs and trying to get a DTD file to define an entity for me, but the entity never gets defined. Looking for some insight. Here are the files I'm working with: ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.