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

Re: Remove adjacent whitespace when removing element

Subject: Re: Remove adjacent whitespace when removing element
From: Hermann Stamm-Wilbrandt <STAMMW@xxxxxxxxxx>
Date: Fri, 15 Nov 2013 09:14:53 +0100
Re:  Remove adjacent whitespace when removing element
Adding
<xsl:template match="text()[preceding-sibling::*[1]=preceding-sibling::b
[1]]"/>

results in
$ xsltproc ws.xsl data.xml
<data>
<a>this is a</a>
<c>this is c</c>
</data>
$


Mit besten Gruessen / Best wishes,

Hermann Stamm-Wilbrandt
Level 3 support for XML Compiler team and Fixpack team lead
WebSphere DataPower SOA Appliances
https://www.ibm.com/developerworks/mydeveloperworks/blogs/HermannSW/
https://twitter.com/HermannSW/     http://www.stamm-wilbrandt.de/ce/
----------------------------------------------------------------------
IBM Deutschland Research & Development GmbH
Vorsitzende des Aufsichtsrats: Martina Koederitz
Geschaeftsfuehrung: Dirk Wittkopp
Sitz der Gesellschaft: Boeblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294


                                                                                                                                     
  From:       Karl Stubsjoen <kstubs@xxxxxxxxx>                                                                                      
                                                                                                                                     
  To:         xsl-list@xxxxxxxxxxxxxxxxxxxxxx,                                                                                       
                                                                                                                                     
  Date:       11/15/2013 04:59 AM                                                                                                    
                                                                                                                                     
  Subject:     Remove adjacent whitespace when removing element                                                                 
                                                                                                                                     





I'm writing a little simple XSLT that translates one Xml to another
and I am cherry picking items from the first Xml for the new Xml and
doing an assortment of other things as well.  All is fine and dandy,
but I'd like to trap the whitespace along with the elements that I am
removing, instead I am getting big gaps in my resulting Xml.  I
reallize that I can turn off indent, but what would be the way to
remove the related whitespace of an element that has been removed?  So
given:

<data>
<a>this is a</a>
<b>this is b</b>
<c>this is c</c>
</data>

If I trap b <xsl:template match="b"/> and do nothing with it my result
looks like:

<data>
<a>this is a</a>

<c>this is c</c>
</data>

Thanks.

Karl..

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.