I have a
problem regarding my XML and self closing tags.
An example is an <img src=”…” /> will be rendered as so <img src=”…”>
- without the close tag “/”
The reason for this is that you have instructed the parser to render HTML instead of XML.
In this linethe output should be changed to xml.
EDIT: This will probably mess up your layout since I suspect the empty <div class="clear"></div> will collapse so in order to make sure that does not happen write it as either <div class="clear"><xsl:text> </xsl:text></div>, which will insert an empty space or use <div class="clear"><xsl:comment /></div>, which will render an html comment like <!-- --> in the output.
Sometimes it's so plain simple to find an answer yourself, which also costs less time than creating/typing this topic. So I thought I'd just point the topicstarter in the right direction. Maybe that'll also help for the next time.
Problem with self closing tags
I have a problem regarding my XML and self closing tags.
An example is an <img src=”…” /> will be rendered as so <img src=”…”> - without the close tag “/”
An example of one macro
<?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"
exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets ">
<xsl:output method="html" omit-xml-declaration="yes" />
<xsl:param name="currentPage"/>
<xsl:variable name="level" select="2"/>
<xsl:template match="/">
<xsl:for-each select="$currentPage/ancestor-or-self::* [@level=$level]/* [@isDoc and string(umbracoNaviHide) != '1']">
<div class="divMenuItem">
<div class="divMenuText">
<a style="text-decoration:none" href="{umbraco.library:NiceUrl(@id)}">
<b><xsl:value-of select="@nodeName"/></b>
</a>
</div>
<div class="divMenuSeperator">
<img alt="seperator" src="/media/2294/menuseperator.png" />
</div>
<div class="clear"></div>
</div>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
Regards Martin
Hi Martin
The reason for this is that you have instructed the parser to render HTML instead of XML.
In this linethe output should be changed to xml.
EDIT: This will probably mess up your layout since I suspect the empty <div class="clear"></div> will collapse so in order to make sure that does not happen write it as either <div class="clear"><xsl:text> </xsl:text></div>, which will insert an empty space or use <div class="clear"><xsl:comment /></div>, which will render an html comment like <!-- --> in the output.
Hope this helps.
/Jan
Really hard to search indeed :-/
http://www.google.com/search?q=umbraco+xslt+self+closing
First hit: http://our.umbraco.org/wiki/how-tos/xslt-useful-tips-and-snippets/stop-html-tags-from-self-closing
@Kip: Remember...this is the most friendly community... :-)
/Jan
Yes it is, and I was not being non-friendly ;-)
Sometimes it's so plain simple to find an answer yourself, which also costs less time than creating/typing this topic. So I thought I'd just point the topicstarter in the right direction. Maybe that'll also help for the next time.
Cool, maybe I just read it wrong :)
/Jan
Regarding the http://our.umbraco.org/wiki/how-tos/xslt-useful-tips-and-snippets/stop-html-tags-from-self-closing link - i read it.
Ive tried
<xsl:text disable-output-escaping="yes"><img alt="seperator" src="/media/2294/menuseperator.png"/></xsl:text>
<xsl:text disable-output-escaping="yes"><![CDATA[<img alt="seperator" src="/media/2294/menuseperator.png" />]]></xsl:text>
Didnt do the trick
@Jan - Thanks for the <div class="clear"><xsl:comment /></div>... now the menu dosnt collapse when useing the output mothod = "xml"
Hi Martin
Happy to hear you got it working :-)
Please mark the post as solved so others can also benefit from the solution.
Have a great day.
/Jan
Or, like the link suggests, use a non breaking space: <divclass="clear"> </div>
is working on a reply...