xsl-list
[Top] [All Lists]

Re: Grouping for noobs

2005-01-26 12:22:03
Tempore 16:04:43, die 01/26/2005 AD, hinc in xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com scripsit Wade Turland <Wade(_dot_)Turland(_at_)optus(_dot_)net(_dot_)au>:

I have this XML:

<text:p text:style-name="Normal"/>
<text:p text:style-name="Preformatted Text"># ps -ef | grep syslog</text:p> <text:p text:style-name="Preformatted Text"> root 194 1 0 Apr 02 ? 53:44 /usr/sbin/syslogd</text:p>
<text:p text:style-name="Preformatted Text"></text:p>
<text:p text:style-name="Normal"/>
<text:p text:style-name="Preformatted Text"># netstat -an | grep 514</text:p> <text:p text:style-name="Preformatted Text"> *.514 Idle</text:p> <text:p text:style-name="Preformatted Text"> *.514 *.* 0 0 24576 0 LISTEN</text:p>
<text:p text:style-name="Normal"/>

and I want it to look like this:

<verbose>
# ps -ef | grep syslog
    root   194     1  0  Apr 02 ?       53:44 /usr/sbin/syslogd

</verbose>

<verbose>
# netstat -an | grep 514</text:p>
      *.514                                 Idle
*.514 *.* 0 0 24576 0 LISTEN
</verbose>
Hi,

Try something like this:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; xmlns:text="t">

<xsl:output indent="yes"/>

<xsl:template match="text:p"/>

<xsl:template match="text:p[(_at_)text:style-name='Normal'][following-sibling::text:p]">
        <verbose>
                <xsl:apply-templates select="." mode="group"/>
        </verbose>
</xsl:template>

<xsl:template match="text:p" mode="group">
        <xsl:apply-templates/>
        <xsl:text>
        </xsl:text>
<xsl:apply-templates select="following-sibling::text:p[1][(_at_)text:style-name='Preformatted Text']" mode="group"/>
</xsl:template>

</xsl:stylesheet>



regards,
--
Joris Gillis (http://www.ticalc.org/cgi-bin/acct-view.cgi?userid=38041)
Vincit omnia simplicitas
Keep it simple

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