Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 11th, 2008, 12:10 PM
Registered User
 
Join Date: Nov 2008
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default Using normalize-space() eg. with position()

Hi!

I have an XML file, but the way an xslt applied to it works depends on the whitespaces. Now that won't do. Any solution will do, but I don't know how I can either

a) put the whole xml through normalize-space() or
b) combine normalize-space to apply-templates or
c) get the position() of a node after processing it with the normalize-space, as position() doesn't allow any inputs.



 
Old November 11th, 2008, 12:18 PM
Friend of Wrox
 
Join Date: Nov 2007
Posts: 1,243
Thanks: 0
Thanked 245 Times in 244 Posts
Default

Do you know xsl:strip-space?
Code:
<xsl:strip-space elements="*"/>
http://www.w3.org/TR/xslt#strip

If that does not help then you need to describe in more detail what exactly the problems are you encounter.

--
  Martin Honnen
  Microsoft MVP - XML
 
Old November 11th, 2008, 12:25 PM
Registered User
 
Join Date: Nov 2008
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
quote:Originally posted by Martin Honnen
 Do you know xsl:strip-space?
Code:
<xsl:strip-space elements="*"/>
http://www.w3.org/TR/xslt#strip

If that does not help then you need to describe in more detail what exactly the problems are you encounter.
ed: just a sec... so it goes outside all templates...
 
Old November 11th, 2008, 12:27 PM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

<xsl:strip-space> is a top level element, so put it before all your templates, not in one.

/- Sam Judson : Wrox Technical Editor -/
 
Old November 11th, 2008, 12:28 PM
Friend of Wrox
 
Join Date: Nov 2007
Posts: 1,243
Thanks: 0
Thanked 245 Times in 244 Posts
Default

Well I pointed you to the documentation.
You need to use xsl:strip-space as a child of xsl:stylesheet e.g.
Code:
<xsl:stylesheet
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  version="1.0">

  <xsl:strip-space elements="*"/>


</xsl:stylesheet>
--
  Martin Honnen
  Microsoft MVP - XML
 
Old November 11th, 2008, 12:30 PM
Registered User
 
Join Date: Nov 2008
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
quote:Originally posted by samjudson
 <xsl:strip-space> is a top level element, so put it before all your templates, not in one.

/- Sam Judson : Wrox Technical Editor -/
Yeah, just figured that out. Thanks for the help for both. It works now.






Similar Threads
Thread Thread Starter Forum Replies Last Post
Strangely working XSLT function normalize-space() seetaramayya XSLT 2 April 23rd, 2007 06:26 AM
normalize-space() gantait XSLT 0 February 26th, 2007 03:29 AM
Looks like a space but it isn't. rstelma SQL Server 2000 3 September 7th, 2005 07:17 PM
space crmpicco Javascript How-To 1 February 7th, 2005 01:26 PM
Normalize-space() not working AForgue XSLT 4 December 5th, 2003 12:39 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.