Which is illegal (X)HTML so the browser compensates by duplicating some elements, which is what you see when using the Firebug (or similar) DOM Inspector.
You *can* switch the output method to "html", which will generate correct HTML for you, but that can be tricky if you're not very confident in where your generated XML/HTML is used.
Usually the best option is to use an if statement and check the stuff you're about to output, to make sure that there's actual content - otherwise put an empty comment inside the tag, to make sure it doesn't collapse, e.g.:
Problem with spaces between tags in XSLT
Hello friends I have a problem with umbraco 4.5 in xslt
Consequently, when inserted for example that:
<a href="#" class="sidebar-item"> </ a>
<div class="clear"> </ div>
This happens:
<a href="#" class="sidebar-item">
<div class="clear"> </ div>
</ a>
But doing this <a href="#" class="sidebar-item"> </ a>, I work, but not a good practice, and I would not think of this as a solution.
It is as if the label "<a>" group itself to other labels and this is a big problem. Help me please!
To create a space you need to wrap it in xsl:text.
Like;
<xsl:text> </xsl:text>
Otherwise it throws a tassy and mucks all the rendered HTML up afterwards.
Make sure you wrap everything in if statements as well - just in case the item, doesn't exist.
Otherwise you'll likely end up with the same problem.
Cheers!
:)
Hi umbracocool,
This actually happens because of this setting in the stylesheet (XSLT):
In XML there's no difference between an element with a million spaces and one with none, so the output generated is actually this:
Which is illegal (X)HTML so the browser compensates by duplicating some elements, which is what you see when using the Firebug (or similar) DOM Inspector.
You *can* switch the output method to "html", which will generate correct HTML for you, but that can be tricky if you're not very confident in where your generated XML/HTML is used.
Usually the best option is to use an if statement and check the stuff you're about to output, to make sure that there's actual content - otherwise put an empty comment inside the tag, to make sure it doesn't collapse, e.g.:
/Chriztian
Hey brothers, thanks very much indeed, both methods helped me, God bless you and thanks for your time. A greeting!
is working on a reply...