[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
[xsl] Grouping for noobs
Subject: [xsl] Grouping for noobs From: "Wade Turland" <Wade.Turland@xxxxxxxxxxxx> Date: Thu, 27 Jan 2005 02:04:43 +1100 |
Hi all Forgive my noobiness, but I did check Dave Pawson's FAQs. 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> Here's what I've got so far: <!-- Text blocks --> <xsl:template match="//text:p"> <xsl:variable name="cur-style-name"> <xsl:value-of select="@text:style-name"/> </xsl:variable> <xsl:variable name="text" select="."/> <xsl:if test="$text!=''"> <!-- these are all newline rules --> <xsl:choose> <!-- for elements inside a Preformatted Text block --> <xsl:when test="$cur-style-name='Preformatted Text' and following-sibling::text:p"> <!-- Group 'Preformatted Text' into a verbose block --> <verbose> <xsl:for-each select="text:p"> <xsl:apply-templates/> <xsl:text disable-output-escaping="yes"> </xsl:text> </xsl:for-each> </verbose> </xsl:when> <xsl:otherwise> <xsl:text disable-output-escaping="yes"> </xsl:text> </xsl:otherwise> </xsl:choose> </xsl:if> </xsl:template> and this produces: # ps -ef | grep syslog<verbose></verbose> root 194 1 0 Apr 02 ? 53:44 /usr/sbin/syslogd<verbose></verbose> # netstat -an | grep 514<verbose></verbose> *.514 Idle<verbose></verbose> *.514 *.* 0 0 24576 0 LISTEN<verbose></verbose> All help appreciated. TIA. Wade.
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] How to save output of XSL, Pieter Reint Siegers | Thread | Re: [xsl] Grouping for noobs, Joris Gillis |
Re: [xsl] Removing line-feeds on a , David Carlisle | Date | [xsl] struggling with <xsl:analyze-, Huditsch Roman |
Month |