Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > DocBook custom XSL transformations

Reply
Thread Tools

DocBook custom XSL transformations

 
 
Szymon Nieradka
Guest
Posts: n/a
 
      05-11-2006
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
 
Reply With Quote
 
 
 
 
Peter Flynn
Guest
Posts: n/a
 
      05-11-2006
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/
 
Reply With Quote
 
 
 
 
Szymon Nieradka
Guest
Posts: n/a
 
      05-12-2006
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
 
Reply With Quote
 
Joe Kesselman
Guest
Posts: n/a
 
      05-12-2006
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
 
Reply With Quote
 
Peter Flynn
Guest
Posts: n/a
 
      05-13-2006
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/
 
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
Miscellaneous issues with tex4ht, xml and xsl transformations Geico Caveman XML 0 10-02-2008 06:34 PM
DocBook: Pass DocBook-Path to Stylesheet tthunder@gmx.de XML 1 11-27-2007 12:08 AM
Transform XML docbook to HTML with docbook stylesheet Antonio Amato XML 2 11-18-2004 05:08 PM
Performance of Xsl Transformations George Durzi ASP .Net 1 12-31-2003 05:58 PM
how to apply two XSL transformations to one XML file Franck Perrin XML 0 07-14-2003 09:22 PM



Advertisments