OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.


Help: OASIS Mailing Lists Help | MarkMail Help

docbook-apps message

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]

Subject: Re: [docbook-apps] How to transform the content of a <para> element ?

While Maxime's example will indeed process all the text node descendants of a para, it will string them together without any emphasis markup (but with translated characters), and then the content will be repeated because the xsl:apply-templates follows in the template.
In general it is difficult to construct a template for a mixed content element like para that processes the text in both text nodes and child elements while retaining the properties of the child elements.  Taking string values of the child elements loses  the element markup.

Instead, I would suggest you create a template that handles the text node descendants of para and not customize the template for para at all.  Something like this:
<xsl:template match="d:para//text()">
  <xsl:value-of select="translate(.,'T','Z')" />

Instead of matching on d:para, this template matches on any text() node descendant of d:para (note the double slash).  Since the template is only acting on text, you don't have to worry about converting child elements to text.  So the only action the template has to take it to translate the characters in the current text node.  This will preserve the emphasis element markup, and reach down as deeply into the text node descendants as is needed.
Bob Stayton
Sagehill Enterprises
----- Original Message -----
Sent: Wednesday, May 25, 2011 5:13 AM
Subject: Re: [docbook-apps] How to transform the content of a <para> element ?


In the <xsl:variable name="texte" select="translate(text(),'T','Z')" /> statement, the 'text()' function only selects the direct child text node(s)(I think only the first actually) of the para element. Try this:

<xsl:variable name="texte">
    <xsl:for-each select=".//text()">
        <xsl:value-of select="translate(.,'T','Z')" />

I hope this helps.

Maxime Bégnis
Tél: - Fax:
5, rue de la Touloubre
13770 Venelles

Le 25/05/2011 13:24, Christophe HARO a écrit :
9757643.11934161306322642414.JavaMail.root@spooler4-g27.priv.proxad.net type="cite">
Hi all,

With an element <para> like this :

  This is a test.
    This is another phrase.

I want to obtain : Zhis is a test. Zhis is another phrase.
where 'Z' replaces all occurrences of 'T'.

The customization layer is :

<!-- Essai de substitution -->
<xsl:template match="db5:para">
  <xsl:variable name="texte" select="translate(text(),'T','Z')" />
  <fo:block xsl:use-attribute-sets="normal.para.spacing">
	  <xsl:value-of select="$texte" />
	  <xsl:call-template name="anchor" />
	  <xsl:apply-templates />

The content of <para> is outputed like this  : Zhis is a test. This is a test. This is another phrase.

1) I do not understand why the content before <emphasis> is outputed two times ;
2) how can I customize so that the content of <emphasis> will be also translated.

For the first point, I think that $texte is outputed (Zhis is a test.) and then <apply-templates> output This is a test. Is that right ?

Can someone help me ?

Many thanks. 

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]