This sounds like a self-closing XML tags issue. Try this:
<!-- here is our nodes tree -->
<xsl:variable name="relations">
<relation><node id="1"><xsl:value-of select="''" /></node></relation>
<relation><node id="2"><xsl:value-of select="''" /></node></relation>
<relation><node id="3"><xsl:value-of select="''" /></node></relation>
<relation><node id="4"><xsl:value-of select="''" /></node></relation>
<relation><node id="5"><xsl:value-of select="''" /></node></relation>
</xsl:variable>
It's basically just putting empty strings into the nodes to prevent them from self-closing. There are other ways to prevent self-closing tags, but I tend to use this one as it's clear and simple and (usually!) reliable.
copy of child node returns open node tag in foreach loop
Hi, I'm using umbraco v 4.7.2 (Assembly version: 1.0.4500.21031)
I have simplified my code to make it easier to read and understand, here is the code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xsl:stylesheet [ <!ENTITY nbsp " "> ]>
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxml="urn:schemas-microsoft-com:xslt"
xmlns:umbraco.library="urn:umbraco.library" xmlns:Exslt.ExsltCommon="urn:Exslt.ExsltCommon" xmlns:Exslt.ExsltDatesAndTimes="urn:Exslt.ExsltDatesAndTimes" xmlns:Exslt.ExsltMath="urn:Exslt.ExsltMath" xmlns:Exslt.ExsltRegularExpressions="urn:Exslt.ExsltRegularExpressions" xmlns:Exslt.ExsltStrings="urn:Exslt.ExsltStrings" xmlns:Exslt.ExsltSets="urn:Exslt.ExsltSets" xmlns:tagsLib="urn:tagsLib" xmlns:BlogLibrary="urn:BlogLibrary" xmlns:autofolders.library="urn:autofolders.library" xmlns:youtube="urn:youtube"
exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets tagsLib BlogLibrary autofolders.library youtube ">
<xsl:output method="xml" omit-xml-declaration="yes"/>
<xsl:param name="currentPage"/>
<xsl:template match="/">
<!-- here is our nodes tree -->
<xsl:variable name="relations">
<relation><node id="1"></node></relation>
<relation><node id="2"></node></relation>
<relation><node id="3"></node></relation>
<relation><node id="4"></node></relation>
<relation><node id="5"></node></relation>
</xsl:variable>
<xsl:variable name="relationNodes" select="msxml:node-set($relations)" />
<xsl:variable name="nodes">
<xsl:for-each select="$relationNodes/*">
<xsl:copy-of select="./node"/>
</xsl:for-each>
</xsl:variable>
<xsl:copy-of select="$nodes"/>
</xsl:template>
</xsl:stylesheet>
this code produces nodes in very strange format having all closing tags in the end:
<node id="1">
<node id="2">
<node id="3">
<node id="4">
<node id="5"></node>
</node>
</node>
</node>
</node>
But what I need is obviosly that:
<node id="1"></node>
<node id="2"></node>
<node id="3"></node>
<node id="4"></node>
<node id="5"></node>
What am I doing wrong?
Hi Denis,
This sounds like a self-closing XML tags issue. Try this:
It's basically just putting empty strings into the nodes to prevent them from self-closing. There are other ways to prevent self-closing tags, but I tend to use this one as it's clear and simple and (usually!) reliable.
I hope this resolves it anyhow...
is working on a reply...