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

Re: normalize-space and the identity template

Subject: Re: normalize-space and the identity template
From: Jeff Sese <jeferson.sese@xxxxxxxxxxxx>
Date: Wed, 5 May 2010 12:00:46 +0800
Re:  normalize-space and the identity template
You can use:

<template match="text()"> to match the all text nodes then use the normalize space inside it.

-- Jeff

On 05 5, 10, at 11:54 AM, Keith Gilbert wrote:

I have the following xml:

<Company>
     <Title>Federal Civil Trial </Title>
     <Author>by John Doe </Author>
     <Body>Blah blah blah blah blah. </Body>
</Company>

I need to remove the extra spaces that sometimes occur before the end-tags.

I've been messing around with the identity template, and can get that to copy my XML intact.

The following trims the spaces before the end-tags nicely.

<xsl:template match="Company/Title">
     <xsl:copy><xsl:value-of select="normalize-space()"/></xsl:copy>
</xsl:template>
<xsl:template match="Company/Author">
     <xsl:copy><xsl:value-of select="normalize-space()"/></xsl:copy>
</xsl:template>

But what I'm wondering is if there's a way to use the identity template to copy the whole tree, but still somehow use normalize- space to remove the spaces. This would enable me to not have to match each element of the tree individually (there are a lot of possible elements).

I can't quite get me head around this one. Any pointers in the right direction are appreciated.

BTW, I'm stuck having to use XSL 1.0 for this project.

~ Keith

Keith Gilbert
Adobe Certified Instructor: ID, IC, AI, PS, AA
Adobe Community Professional
blog.gilbertconsulting.com


Jeferson L. Sese jeferson dot sese at asiatype dot com Asiatype Inc. Suite 114 Columbia Tower Ortigas Ave., Greenhills Mandaluyong City 1550 Philippines Tel: +632-744-6262 Mobile: +63927-671-7901

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.