I'm just making this post due to a problem I encountered with one of my xslt files that was doing my head in. I finally found the problem and thought it may be useful to anyone else who's had the problem.
Basically I had the following (simplified) code in my xslt file:
I couldn't work out why the rendered code had duplicate anchor tags. I figured my anchor tags were outside the loop so there should only be two instances of the anchors... however I was seeing duplicates.
It turns out that it was something to do with the anchor tags being empty. If i put either another element or even within the tags, everything appears to render correctly.
I realise that people may already be aware of this but I was struggling with it for quite some time today! I hope it helps someone out there..
Duplicate elements bug
Hiya,
I'm just making this post due to a problem I encountered with one of my xslt files that was doing my head in. I finally found the problem and thought it may be useful to anyone else who's had the problem.
Basically I had the following (simplified) code in my xslt file:
<ul id="secondary-nav">
<xsl:for-each select="$selectedNode/descendant::* [@isDoc and string(umbracoNaviHide) != '1']">
<li>
...
</li>
</xsl:for-each>
<li>
<a href="#" target="_blank"></a>
<a href="#" target="_blank"></a>
</li>
</ul>
I couldn't work out why the rendered code had duplicate anchor tags. I figured my anchor tags were outside the loop so there should only be two instances of the anchors... however I was seeing duplicates.
It turns out that it was something to do with the anchor tags being empty. If i put either another element or even within the tags, everything appears to render correctly.
I realise that people may already be aware of this but I was struggling with it for quite some time today! I hope it helps someone out there..
Hi Alimac
When the output method of the XSLT file is set to "XML" the empty tags will collapse when the code is rendered, which can break havoc on the layout.
You can change the output method to HTML but it's not alway ideal or an option since it can break other stuff depending on the context.
So as you mention can be used or you can simply just do this <xsl:text> </xsl:text> or use <xsl:comment>Empty comment</xsl:comment>
/Jan
is working on a reply...