xsl-list
[Top] [All Lists]

Re: [xsl] Mixed content, separation

2012-02-29 03:16:51

Seemed uncessarily complex, but that works.
I tripped up over
...
<ul>
Isolate
<i>inlined</i>
</ul>
After content, <b>....</b></p>
<Afterwards/>

which yours caught.
Thanks.

Hi Dave,

You could use grouping with adjacent

     <xsl:template match="p">
         <xsl:for-each-group select="node()"
group-adjacent="if(self::ul | self::dl) then(generate-id())
else('inline')">
             <xsl:choose>
                 <xsl:when test="current-grouping-key() = 'inline'">
                     <p>
                         <xsl:apply-templates select="current-group()"/>
                     </p>
                 </xsl:when>
                 <xsl:otherwise>
                     <xsl:apply-templates select="current-group()"/>
                 </xsl:otherwise>
             </xsl:choose>
         </xsl:for-each-group>
     </xsl:template>

     <xsl:template match="node()">
         <xsl:copy>
             <xsl:copy-of select="@*"></xsl:copy-of>
             <xsl:apply-templates select="node()"></xsl:apply-templates>
         </xsl:copy>
     </xsl:template>

since you don't know what the inlines are, I hope you know what the
block elements are
you can make the test for block better yourself I guess



At 09:37 29/02/2012, you wrote:
given
<p> text1 <i>italic</i>
<ul>
...
</ul>
text 2</p>
or
<p> text1 <i>italic</i>
<dl>
...
</dl>
text 2</p>

How can I produce

<p> text1 <i>italic</i></p>
<ul>
...
</ul>
<p>text 2 (any other inlines)</p>

I.e. isolate the block elements...

nasty side:
   I'm unsure of the list of inline elements!

any suggestions appreciated.

Dave



--~------------------------------------------------------------------
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>
--~--





--~------------------------------------------------------------------
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>
--~--