[xsl] something like merge subparts of a branche

Subject: [xsl] something like merge subparts of a branche
From: simon litwan <simon.litwan@xxxxxxxxx>
Date: Tue, 26 Apr 2005 11:25:49 +0200
hi list

i'm pretty new to xsl and try to solve a problem that goes over my
abilities. but maybe somebody can help me.
i'm working with apache-lenya.
the problem is like this.
i have a source tree like this.

<p>
   <a href="http://www.hello.ch/"; title="">
     minus eins und null
   </a>
   <object data="important.gif" href="" title="important"
type="image/gif">erstes</object>
   <a href="http://www.hello.ch/"; title="">
     eins zwei
   </a>
   drei und noch was
   <object data="important.gif" href="" title="important"
type="">zweites</object>
   vier und noch mehr
   <a href="http://www.hello.ch/"; title="">
     fuenf sechs
   </a>
</p>

and the result should be like this:

<p>
   <a href="http://www.hello.ch/"; title="">
     minus eins und null
   </a>
</p>
<p>
   <object data="important.gif" href="" title="important"
type="image/gif">erstes</object>
</p>
<p>
   <a href="http://www.hello.ch/"; title="">
     eins zwei
   </a>
   drei und noch was
</p>
<p>
   <object data="important.gif" href="" title="important"
type="">zweites</object>
</p>
<p>
   vier und noch mehr
   <a href="http://www.hello.ch/"; title="">
     fuenf sechs
   </a>
</p>

at the moment my xsl looks like that.

  <xsl:template match="xhtml:p[xhtml:object]" priority="3">

    <xsl:choose>
      <xsl:when test="node()[not(self::xhtml:object) and
normalize-space() != '']">
        
        <xsl:for-each select="node()">
          <xsl:choose>
            <xsl:when test="self::xhtml:object">
       
              <xsl:apply-templates
select="self::xhtml:object"></xsl:apply-templates>
            
            </xsl:when>
            <xsl:otherwise>
            <p>
              <xsl:apply-templates select="."></xsl:apply-templates>
            </p>
            </xsl:otherwise>
          </xsl:choose>
        </xsl:for-each>
        
      </xsl:when>
      <xsl:otherwise>
      
        <xsl:apply-templates select="xhtml:object"/> 
      
      </xsl:otherwise>
    </xsl:choose>
    
  </xsl:template>


but it's certainly not like that. i do not know how to merge the all
siblings befor an xhtml:object under a paragraf but not the
xhtml:object. and then merge again the nodes between the xhtml:object
and so on.

i tried different ways. 
for example a for-each for each xhtml:object and then get the siblings
around xhtml:object with preceding-sibling/following-sibling. the
problem with this aproach is that if there ar several xhtml:object in
the paragraph i don't know how to limit the following-sibling just to
the next xhtml:object.

i'm not sure my explanation is good enough.
anyway thanks for any help.
simon

Current Thread