[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

grouping like items into one

Subject: grouping like items into one
From: Fred Christian <fredc@xxxxxxxxxx>
Date: Thu, 22 Jan 2009 17:37:14 -0800
 grouping like items into one
I know I have done this with xsl 1.0 before and could figure it out, but 1.0 is painful :)
So I am trying to figure it out with 2.0 and am getting stuck. I am running into that "how do I know what to look up if I don't know how to spell it" jam.
I looked at the xsl:for-each-group element, but I don't think that will work in this situation.
Someone want to take a whack at it?

I want to group bordered text into one border <span>, but leave italic text ( and other styles ) in individual nodes.

_______Source XML__________________
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<text italic="false" border="">a </text>
<text italic="false" border="single">b </text>
<text italic="true" border="single">c </text>
<text italic="true" border="">d </text>
<text italic="false" border="">e </text>
<text italic="false" border="single">f </text>
<text italic="false" border="single">g </text>
<text italic="false" border="">h </text>
<text italic="true" border="single">i </text>
<text italic="true" border="">j </text>

_____Current output (formated for readability)________________
<span class="border">b </span>
<span class="border"><i>c </i></span>
<i>d </i>
<span class="border">f </span>
<span class="border">g </span>
<span class="border"><i>i </i></span>
<i>j </i>

____ Desired output (formated for readability) ______________
____ Note how there is one <span....> around b <i>c </> and around "f g " ___
<span class="border">b <i>c </i></span>
<i>d </i>
<span class="border">f g </span>
<span class="border"></span>
<i>i </i>
<i>j </i>

_____________ current xsl _______________
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
exclude-result-prefixes="xs saxon">

<xsl:template match="/DD">

<xsl:template match="text">
<xsl:when test="@border='single'">
<span class="border"><xsl:apply-templates select="." mode="moreStyles"/></span>
<xsl:otherwise><xsl:apply-templates select="." mode="moreStyles"/></xsl:otherwise>

<xsl:template match="text" mode="moreStyles">
       <xsl:when test="./@italic='true'">


Current Thread


Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
First Name
Last Name
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.