 |
| 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
|
|
|
|

October 20th, 2010, 09:55 AM
|
|
Authorized User
|
|
Join Date: Oct 2010
Posts: 25
Thanks: 8
Thanked 0 Times in 0 Posts
|
|
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>
</xsl:text>
don't want to add this after each <xsl:element>, there are too many.
regards,
Ehsan
|
|

October 20th, 2010, 10:25 AM
|
 |
Wrox Author
|
|
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
|
|
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
|
|

October 20th, 2010, 10:31 AM
|
|
Authorized User
|
|
Join Date: Oct 2010
Posts: 25
Thanks: 8
Thanked 0 Times in 0 Posts
|
|
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.
|
|

October 20th, 2010, 10:36 AM
|
|
Friend of Wrox
|
|
Join Date: Nov 2007
Posts: 1,243
Thanks: 0
Thanked 245 Times in 244 Posts
|
|
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
|
|

October 20th, 2010, 11:10 AM
|
 |
Wrox Author
|
|
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
|
|
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
|
|

October 21st, 2010, 09:43 AM
|
|
Authorized User
|
|
Join Date: Oct 2010
Posts: 25
Thanks: 8
Thanked 0 Times in 0 Posts
|
|
How do I find out if I'm using the XSLT serializer? For writing and debuging I am using Visual studio 2010.
|
|

October 21st, 2010, 09:54 AM
|
|
Friend of Wrox
|
|
Join Date: Nov 2007
Posts: 1,243
Thanks: 0
Thanked 245 Times in 244 Posts
|
|
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
|
|

October 21st, 2010, 10:28 AM
|
|
Authorized User
|
|
Join Date: Oct 2010
Posts: 25
Thanks: 8
Thanked 0 Times in 0 Posts
|
|
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.
|
|

October 21st, 2010, 10:47 AM
|
 |
Friend of Wrox
|
|
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
|
|
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.
|
|

October 22nd, 2010, 09:45 AM
|
|
Authorized User
|
|
Join Date: Oct 2010
Posts: 25
Thanks: 8
Thanked 0 Times in 0 Posts
|
|
Thank you VS for the Find and Replace function :-) used the <xsl:text>
</xsl:text> at the end of each element.
|
|
 |