ASP Error: 70
Description: Permission denied
Source: Microsoft VBScript runtime error

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

Re: Merging adjacent nodes of same type

Subject: Re: Merging adjacent nodes of same type
From: David Carlisle <davidc@xxxxxxxxx>
Date: Fri, 23 Sep 2005 12:31:39 +0100
normalize adjacent text nodes
> Is it possible without this?

oh everything's possible, just different.

This is a fairly standard grpuping question (google your way to jeni's
site)

You have to be a bit careful about what exactly you mean by adjacent
your <text> element has mixed content: element nodes and text nodes as
children so normally you wouldn't ignore text nodes in that case
which would mean that your offset elements were not adjacent (being
separated by some whitespace). 
so assuming your real example does have "Some text" and not
<foo>Some text</foo> you can't test for preceding-sibling::*[1] as that
would not see the text nodes, and you can't test for
preceding-sibling::node()[1] as that would see the white space text,
so by adjacent you mean
preceding-sibling::node()[self::* or normalize-space(.)][1] 
that is the nearest sibling that is an element or has non whitespace
characters in its string value.

so something like:


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


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

<xsl:template match="offset[not(node())]">
<xsl:param name="a" select="/.."/>
<xsl:choose>
<xsl:when test="
   following-sibling::node()[self::* or normalize-space(.)][1]/self::offset[not(node())]">
 <xsl:apply-templates select="following-sibling::offset[1]">
  <xsl:with-param name="a" select="$a|@*"/>
 </xsl:apply-templates>
</xsl:when>
 <xsl:otherwise>
<offset  x="{sum($a[name()='x']|@x)}"  y="{sum($a[name()='y']|@y)}" z="{sum($a[name()='z']|@z)}"/>
<xsl:apply-templates select="following-sibling::node()[1]"/>
 </xsl:otherwise>
</xsl:choose>
</xsl:template>




</xsl:stylesheet>

________________________________________________________________________
This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

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.
Email
First Name
Last Name
Company
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.