473,471 Members | 1,729 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

DocBook custom XSL transformations

Hi,

I'm trying to make a docbook document template. I would like to make
my life easier and instead of writing:

<glosslist>
<glossentry>
<glossterm>C</glossterm>
<glossdef>
<para>
A procedural programming language invented by K&amp;R.
</para>
</glossdef>
</glossentry>
<!-- ... -->
</glosslist>

I'd like to write:

<glosslist>
<glossEntry term="C">
A procedural programming language invented by K&amp;R.
</glossEntry>
<!-- ... -->
</glosslist>

(of course thats only example of use)

I'm making transormations of DocBook file using my custom XSL
stylescheet. This XSL stylescheet have got some default include at the
top (for ex. .../docbook/html/docbook.xsl). Abow I'm putting my addons.
I was trying to do what I want this way:

<xsl:template match="glossEntry">
<!-- (1) -->
<xsl:value-of select="@term"/> <!-- term -->
<!-- (2) -->
<xsl:value-of select="."/> <!-- definition -->
</xsl:template match="glossEntry">

At (1) I have to resolve / call <glossentry> and at (2) I have to do the
same with <glossdef> and <para>. I was trying a lot of combinations of:

<xsl:call-template name="glossentry"/>

and

<xsl:apply-templates select="glossentry"/>

but without success.

Of course I could insert HTML tags diresctly (<dl/>) but I'm not only
interested in HTML, I need also RTF and PDF output.

Any ideas? Is it possible?

--
Szymon Nieradka
May 11 '06 #1
4 1454
Szymon Nieradka wrote:
Hi,

I'm trying to make a docbook document template. I would like to make
my life easier and instead of writing:

<glosslist>
<glossentry>
<glossterm>C</glossterm>
<glossdef>
<para>
A procedural programming language invented by K&amp;R.
</para>
</glossdef>
</glossentry>
<!-- ... -->
</glosslist>

I'd like to write:

<glosslist>
<glossEntry term="C">
A procedural programming language invented by K&amp;R.
</glossEntry>
<!-- ... -->
</glosslist>

(of course thats only example of use)


Why use XSL?
Just redefine the elements involved: that's why DocBook is modular.

dbglossmod.dtd
--------------
<!ENTITY % docbookdtd SYSTEM "/your/path/to/the/docbookx.dtd">

<!ENTITY % glosslist.element "IGNORE">
<!ENTITY % glosslist.attlist "IGNORE">
<!ENTITY % glossentry.element "IGNORE">
<!ENTITY % glossentry.attlist "IGNORE">

%docbookdtd;

<!ELEMENT glosslist %ho; (glossentry+)>
<!ELEMENT glossentry %ho; (%para.char.mix;)*>
<!ATTLIST glossentry term CDATA #REQUIRED>

test.xml
--------
<?xml version="1.0"?>
<!DOCTYPE article SYSTEM "dbglossmod.dtd">
<article>
<glosslist>
<glossentry term="C">A procedural programming language invented by
K&amp;R.</glossentry>
</glosslist>
</article>

///Peter
--
XML FAQ: http://xml.silmaril.ie/
May 11 '06 #2
Peter Flynn wrote:
Why use XSL?
Just redefine the elements involved: that's why DocBook is modular.

dbglossmod.dtd
--------------
<!ENTITY % docbookdtd SYSTEM "/your/path/to/the/docbookx.dtd">

<!ENTITY % glosslist.element "IGNORE">
<!ENTITY % glosslist.attlist "IGNORE">
<!ENTITY % glossentry.element "IGNORE">
<!ENTITY % glossentry.attlist "IGNORE">

%docbookdtd;

<!ELEMENT glosslist %ho; (glossentry+)>
<!ELEMENT glossentry %ho; (%para.char.mix;)*>
<!ATTLIST glossentry term CDATA #REQUIRED>

test.xml
--------
<?xml version="1.0"?>
<!DOCTYPE article SYSTEM "dbglossmod.dtd">
<article>
<glosslist>
<glossentry term="C">A procedural programming language invented by
K&amp;R.</glossentry>
</glosslist>
</article>


I did exactly what You have written. Result using DSSSL stylescheet:

<DIV CLASS="glosslist">
<DL>A procedural programming language invented by K&R.
</DL>
</DIV

and result using XSL stylescheet:

<div class="glosslist">
<dl>
<dt></dt>
</dl>
</div>

I think, the problem is cos we redefine only DTD of glosslist elements
but not behaviour of it. So xml:

<glossentry term="C">...</glossentry>

is valid against DTD, but XSL / DSSSL styles could not correctly
translate this XML.
--
/// Szymon Nieradka
/// http://microbus.pl
May 12 '06 #3
Szymon Nieradka wrote:
<xsl:call-template name="glossentry"/>


1) You did modify the template you're trying to call so it too has
name="glossentry", right?

2) Will its behavior be correct when it's invoked on this node? I'd bet
it recurses downward and so will *not* do what you intend.

Suggestion: Copy the existing template for the standard glossentry, make
the new copy match="glossEntry", and modify its behavior appropriately.
You may (or may not) need to copy in some of the behavior from the
glossdef and para templates as well, since you aren't going to be going
through those.
--
() ASCII Ribbon Campaign | Joe Kesselman
/\ Stamp out HTML e-mail! | System architexture and kinetic poetry
May 12 '06 #4
Szymon Nieradka wrote:
I did exactly what You have written. Result using DSSSL stylescheet:

<DIV CLASS="glosslist">
<DL>A procedural programming language invented by K&R.
</DL>
</DIV

and result using XSL stylescheet:

<div class="glosslist">
<dl>
<dt></dt>
</dl>
</div>

I think, the problem is cos we redefine only DTD of glosslist elements
but not behaviour of it. So xml:

<glossentry term="C">...</glossentry>

is valid against DTD, but XSL / DSSSL styles could not correctly
translate this XML.


XSL and DSSSL that you write will have no problems handling that DTD.

I think what you mean is that the *pre-written* XSL/DSSL DocBook
stylesheets won't handle it. Not surprising: they were written
for the unmodified DTD.

But you said you were using custom XSL. Just edit it to reflect the
DTD changes.

///Peter
--
XML FAQ: http://xml.silmaril.ie/
May 13 '06 #5

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

Similar topics

1
by: Cougarkhan | last post by:
I'm working on some reports, which need will need to be formatted in several different formats. What are some of the recommendations for or against using DocBook XML over a regular XML Document? ...
3
by: Dr. Laurence Leff | last post by:
I am having trouble doing the basics with xmlto on Redhat to convert DocBook XML into the various files. I believe the problem is the first line on the files: Here is starter file (notes.xml):...
2
by: Simon Strandgaard | last post by:
I am trying to understand how to create a 'catalog.xml' file for my docbook-xml documents. If I understand correct a local catalog.xml file can both avoid hardcoding in makefiles (portability),...
3
by: ZJT | last post by:
What are the ways and corresponding tools to transform a docbook document to a pdf document? Thanks a lot!
4
by: bringmewater | last post by:
I'm in Windows XP and wish to convert an xml file that is in docbook format to the following 2 formats: multiple html files single pdf file Are there any free apps that can do this? I need...
2
by: Yarco | last post by:
I'm learning for docbook under win32. I download: openjade-1_3_1-2-bin docbook-xml-4.4 docbook-dsssl-1.79 ldp.dsl And then copy all openjade bin\ to win32 system\, and then create a directory...
1
by: kjcox | last post by:
I've been using DocBook and XML for quite some time now. It works great for making simple HTML pages, http://gnuware.com/icecast/. I normally use it on RHEL and do not customize anything other than...
7
by: mike p. | last post by:
I have a docbook xml file, and am using standard docbook 1.61.3 xsl stylesheets to do xhtml transform. Transform works fine when using MSXML. When I try to do the following using asp.net 1.1: ...
2
by: Joseph Kesselman | last post by:
Since the recent "Docbook on Windows" question brought this up... I did a bit of checking on the current status of these schemas, what they're intended for and how they interrelate. IBM's Robert...
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
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.