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 October 20th, 2010, 09:55 AM
Authorized User
 
Join Date: Oct 2010
Posts: 25
Thanks: 8
Thanked 0 Times in 0 Posts
Default adding a newline at the end of each element

Hello,

Is it possible to force the output of a xslt to include a newline after each element? besides the
Code:
<xsl:text>&#xa;</xsl:text>
don't want to add this after each <xsl:element>, there are too many.

regards,
Ehsan
 
Old October 20th, 2010, 10:25 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

Does <xsl:output indent="yes"/> do what you want?
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference
 
Old October 20th, 2010, 10:31 AM
Authorized User
 
Join Date: Oct 2010
Posts: 25
Thanks: 8
Thanked 0 Times in 0 Posts
Default

I have this at the top of my master xslt file
Code:
<xsl:output method="xml" indent="yes"/>
but it dosen't do the job.
 
Old October 20th, 2010, 10:36 AM
Friend of Wrox
 
Join Date: Nov 2007
Posts: 1,243
Thanks: 0
Thanked 245 Times in 244 Posts
Default

Please explain in more detail how your input XML, stylesheet, current output, desired output looks, which XSLT processor you use and how you look at the transformation result.
__________________
Martin Honnen
Microsoft MVP (XML, Data Platform Development) 2005/04 - 2013/03
My blog
 
Old October 20th, 2010, 11:10 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

If indent="yes" has no effect, it might be because you are not using the XSLT serializer. For example, you might be writing the result tree to a DOM, and then using the DOM serializer.
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference
 
Old October 21st, 2010, 09:43 AM
Authorized User
 
Join Date: Oct 2010
Posts: 25
Thanks: 8
Thanked 0 Times in 0 Posts
Default

How do I find out if I'm using the XSLT serializer? For writing and debuging I am using Visual studio 2010.
 
Old October 21st, 2010, 09:54 AM
Friend of Wrox
 
Join Date: Nov 2007
Posts: 1,243
Thanks: 0
Thanked 245 Times in 244 Posts
Default

Show us the C# or VB.NET code you use to run the XSLT transformation. Make sure you write to a file or stream or if you use write to an XmlWriter make sure you create it with XmlWriter.Create("file.xml", xslCompiledTransformInstance.OutputSettings).
__________________
Martin Honnen
Microsoft MVP (XML, Data Platform Development) 2005/04 - 2013/03
My blog
 
Old October 21st, 2010, 10:28 AM
Authorized User
 
Join Date: Oct 2010
Posts: 25
Thanks: 8
Thanked 0 Times in 0 Posts
Default

There isn't any, I am using VS as a XML/XSLT editor. I just created a blank C# project and added the XMl, XSLT and schemas to the project. So I use the XML Schema explorer to look at my schemas and use the XML menu to run or debug the style sheets, no other code is involved.
 
Old October 21st, 2010, 10:47 AM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

I've tried this in Visual Studio 2010, and the indent="yes" does make a difference to the output.

However, if I remember correctly Microsoft's XSLT processor also gives importance to whitespace found in the input XML, so you might want to try adding the following to your XSLT file as well and see what you get:

Code:
<xsl:strip-space elements="*"/>
If that still doesn't work then an example of your input XML and XSLT files will be needed.
__________________
/- Sam Judson : Wrox Technical Editor -/

Think before you post: What have you tried?
 
Old October 22nd, 2010, 09:45 AM
Authorized User
 
Join Date: Oct 2010
Posts: 25
Thanks: 8
Thanked 0 Times in 0 Posts
Default

Thank you VS for the Find and Replace function :-) used the <xsl:text>&#xa;</xsl:text> at the end of each element.





Similar Threads
Thread Thread Starter Forum Replies Last Post
How to move XML element at end krish XSLT 3 December 15th, 2009 06:58 AM
Problem adding element to the previous element dani1 XSLT 5 September 10th, 2008 01:38 AM
Adding a new Element monuindia2002 XML 2 March 13th, 2006 11:59 PM
adding of element and assigning to one element sushovandatta XSLT 2 November 16th, 2004 07:04 PM
Adding an element to a binded DropDownlist mahulda ASP.NET 1.0 and 1.1 Basics 3 March 10th, 2004 03:12 PM





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