The xsl:text element is a great way to say "don't throw this whitespace out. This revision of the template above shows how xsl:text elements with a single space as content ensure that those spaces end up in the result. When applied to the same source document, the revised stylesheet creates a result with spaces separating the values. The xsl:text elements in this next version of the template each have a single carriage return as their contents instead of a single space.
With the same source document used again, the result of this template has each value separated by a carriage return. This last template isn't indented very nicely. For those two xsl:text elements to each have a single carriage return and only a single carriage return as their contents, their end-tags must be right at the beginning of the line after the start-tag. If they were indented with the rest of the child elements of the xsl:apply-templates element, like this,.
One handy trick that gets around this indenting problem and makes stylesheets more readable is to declare a general entity that has an xsl:text element with a space or carriage return as its contents and then to reference that entity in the document.
This next version of the stylesheet does this for both characters and references these entities to put a carriage return after the hireDate value and a space after the first value. The result has the carriage return and space right where the entity references put them. Usually, stylesheets declare entities like this when they need to be used repeatedly in a document.
An XML processor will not delete a carriage return that's in an element with other character data, but sometimes you don't want that carriage return. The xsl:text element can help here, too, as easily as it can help to add carriage returns. For example, if we want to add the contents of the source document above to the result tree with the labels "Hire Date:" and "Name:" preceding each line, we might try it like this:.
If we don't want those carriage returns, we can wrap those labels in xsl:text elements. This splits the carriage returns after those labels off to where they're no longer next to non-whitespace characters and will therefore be ignored by the XML processor that hands this stylesheet to the XSLT processor. Whether you're trying to add carriage returns or delete them, the xsl:text instruction is great for controlling how carriage returns are added to your result tree.
Automating Stylesheet Creation. Appreciating Libxslt. Push, Pull, Next! Seeking Equality. This makes whitespace following every comma significant, and so it ends up in the output.
Also, get rid of that disable-output-escaping. It doesn't do anything here, since you're not outputting XML. This answer may not direct answer to the problem.
But a general way solve this issue. Create a template rule:. Hope this helps somebody. Modify the code which we used to format raw xml file by removing below lines will remove extra blank white spaces added in exported excel.
Stack Overflow for Teams — Collaborate and share knowledge with a private group. Create a free Team What is Teams? Collectives on Stack Overflow. Learn more.
Asked 12 years, 3 months ago. Active 2 years, 2 months ago. Viewed 74k times. Robert DeBoer. From XSLT 1. Add a comment. Active Oldest Votes. In XSLT, white-space is preserved by default, since it can very well be relevant data. Tomalak Tomalak k 64 64 gold badges silver badges bronze badges. Noah Heldman Noah Heldman 6, 3 3 gold badges 37 37 silver badges 39 39 bronze badges.
W3 Schools! David Andres David Andres Pavel Minaev Pavel Minaev Nick Groznykh Nick Groznykh 19 1 1 bronze badge. Cylian Cylian Thank you your answer, but give always more info. While formatting with indented property system is adding those extra blank white spaces. Comment lines related to formatting xml like below line and try.
0コメント