xsl-list
[Top] [All Lists]

RE: detecting text between nodes

2005-02-24 10:13:14
If the context node is a <br/> element, then

    test="preceding-sibling::node()[1][self::br]"

tests whether the immediately preceding node is also a <br/> element.

Michael Kay
http://www.saxonica.com/

 

-----Original Message-----
From: Uwe Janner [mailto:xsl(_at_)janner(_dot_)at] 
Sent: 24 February 2005 16:59
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] detecting text between nodes

dear xsl-specialists,

i try write an xsl to transform html-documents (with a restricted
html-subset) directly to fo.

my only problem is the <br/>-tag:
if i have "aaa<br/>bbb<br/>ccc"
then i simply have to replace each br-tag with a <fo:block/> 
just to insert
a line-break.

but if i have "aaa<br/><br/>bbb" the first br is responsible for the
line-break and the second will insert an empty line, i.e. i 
have to convert
the second br-tag to something that inserts an empty line:
"aaa<fo:block/><fo:block space-after="10"/>bbb"

so, the attribute "space-after=10" is present if the 
preceding sibling is a
"br" and there is nothing except whitespace between the 
current br and the
preceding br;

but how can i express this condition with xpath?

<xsl:template match="br">
  <fo:block>
    <xsl:if test="name(./preceding-sibling::*[1])='br' and
NOTHINGBUTWHITESPACEBETWEEN(.,./preceding-sibling::*[1])">
      <xsl:attribute name="space-after">10pt</xsl:attribute>
    </xsl:if>
  </fo:block>
</xsl:template>


tia for any hint!

fusel!



--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: 
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--





--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



<Prev in Thread] Current Thread [Next in Thread>