Oliver Müller wrote:
Maybe I don't got any other solution because I'm quite new to XSL-FO ...
I would really love to use text-indent, but in my case I don't see a
chance to do so.
[....]
I found no possibility to apply a new fo:block to all of the text
before and after

Normally people choose XSLT to do that task, I assume you do so too. The best place to ask that question is on the XSLT list. Try http://www.mulberrytech.com/xsl/xsl-list/subscribe-unsubscribe.html to subscribe to that list.

Since this is fairly trivial to do in XSLT 1 and 2 (what version do you use?), I will give you a solution that works for either version:

INPUT DOC:
<root>
   Lorem ipsum 1
   <absatz />
   Lorem ipsum 2
   <absatz />
   Lorem ipsum 3
</root>

XSLT DOC:
<xsl:stylesheet version="1.0"
   xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
   xmlns:fo="http://www.w3.org/1999/XSL/Format";>
<xsl:output indent="yes"/> <xsl:template match="root">
       <fo:root>
           <xsl:apply-templates />
       </fo:root>
   </xsl:template>
<xsl:template match="text()[preceding-sibling::*[1][self::absatz]]">
       <fo:block text-indent="6pt">
           <xsl:value-of select="."/>
       </fo:block>
   </xsl:template>
</xsl:stylesheet>

OUTPUT:
   <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format";>
       Lorem ipsum 1
       <fo:block text-indent="6pt">
           Lorem ipsum 2
       </fo:block>
       <fo:block text-indent="6pt">
           Lorem ipsum 3
       </fo:block>
   </fo:root>


If you want the first textblock to be indented as well, add the following to the match of the text-nodes with preceding-sibling:

text()[following-sibling::*[1][local-name() = 'absatz']]

or make a copy of it, and add this:

   <xsl:template match="text()[following-sibling::*[1][self::absatz]]">
       <fo:block text-indent="6pt">
           <xsl:value-of select="."/>
       </fo:block>
   </xsl:template>

which will wrap all text nodes that have either a following node or a preceding node that is called "absatz". Note that the following (seemingly correct) versions do not yield the same results:

text()[preceding-sibling::absatz]

which will match the text-node if somewhere, between all siblings, there is a node 'absatz', and

text()[preceding-sibling::absatz[1]]

which will match if there is at least one node, somewhere, that matches the name 'absatz' (same as before) and

text()[preceding-sibling::*[1][absatz]]

which will match if the first sibling has a child 'absatz', which is not what we want. So, finally, this comes to:

text()[preceding-sibling::*[1][local-name() = 'absatz']]

Please note, that this explicitly does not wrap the text inside an fo:block when something else then an <absatz /> node is preceding or following the text node. Also, if the text node you want to match contains more nodes (like text in xhtml with <strong> and <em>), the above solution needs some tweaking (nothing fancy though). In that case, I think your chances are better at the XSLT mailing list.

Note, too, that text nodes that do not match the predicate discussed above, will simply be output.

Hope this helps!

<absatz />.
Thats why I'm using <fo:block /><fo:inline font-size="10pt">&#8195;</fo:inline>
to get my linebreak and indent.

Since you need a linebreak and an indent, you better wrap the texts in a fo:block, like you suggested already.

Cheers,
-- Abel Braaksma
  http://www.nuntia.nl

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to