Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Martin Vingaard 39 posts 60 karma points
    Jul 12, 2011 @ 11:11
    Martin Vingaard
    0

    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 "&#x00A0;"> ]>
    <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">
        
          <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

     

     

     

     

     

     

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Jul 12, 2011 @ 11:19
    Jan Skovgaard
    0

    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

  • Stefan Kip 1614 posts 4131 karma points c-trib
    Jul 12, 2011 @ 11:20
  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Jul 12, 2011 @ 11:22
    Jan Skovgaard
    0

    @Kip: Remember...this is the most friendly community... :-)

    /Jan

  • Stefan Kip 1614 posts 4131 karma points c-trib
    Jul 12, 2011 @ 11:26
    Stefan Kip
    1

    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.

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Jul 12, 2011 @ 11:27
    Jan Skovgaard
    1

    Cool, maybe I just read it wrong :)

    /Jan

  • Martin Vingaard 39 posts 60 karma points
    Jul 12, 2011 @ 11:57
    Martin Vingaard
    0

    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">&lt;img alt="seperator" src="/media/2294/menuseperator.png"/&gt;</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"

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Jul 12, 2011 @ 12:00
    Jan Skovgaard
    0

    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

  • Stefan Kip 1614 posts 4131 karma points c-trib
    Jul 12, 2011 @ 12:01
    Stefan Kip
    0

    Or, like the link suggests, use a non breaking space: <divclass="clear">&nbsp;</div>

Please Sign in or register to post replies

Write your reply to:

Draft