Copied to clipboard

Flag this post as spam?

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


  • Keith Jackson 183 posts 552 karma points
    Jun 01, 2011 @ 12:14
    Keith Jackson
    0

    Header section Macro

    I've built a header section macro to show the content of two properties within several templates, introText and introImage. This is my XSLT so far, but it's not returning any values into the properties. What have I missed here?

    <?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"
        exclude-result-prefixes="msxml umbraco.library">

      <xsl:output method="xml" omit-xml-declaration="yes"/>
      
      <xsl:variable name="imagePath" select="introImage"/>
      
      <xsl:template match="/">
        imagePath = <xsl:value-of select="$imagePath"/><br/>
          <nobr>
          <xsl:if test="$imagePath != '' ">
            <xsl:element name="img">
              <xsl:attribute name="src">
                <xsl:value-of select="$imagePath"/>
              </xsl:attribute>
            </xsl:element>
          </xsl:if>
          &nbsp;&nbsp;
          <h3><xsl:value-of select="introText"/></h3>
          </nobr>
      </xsl:template>

    </xsl:stylesheet>

  • Keith Jackson 183 posts 552 karma points
    Jun 01, 2011 @ 12:26
    Keith Jackson
    0

    UPDATE: I've now done this...

    <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"
        exclude-result-prefixes="msxml umbraco.library">

      <xsl:output method="xml" omit-xml-declaration="yes"/>
       
      <xsl:param name="currentPage"/>
      <xsl:variable name="imagePath" select="$currentPage/introImage"/>
      
      <xsl:template match="/">
          <nobr>
          <xsl:if test="$imagePath != '' ">
            <xsl:element name="img">
              <xsl:attribute name="src">
                <xsl:value-of select="$imagePath"/>
              </xsl:attribute>
            </xsl:element>
          </xsl:if>
          &nbsp;&nbsp;
            <h3><xsl:value-of select="$currentPage/introText"/></h3>
          </nobr>
      </xsl:template>

    </xsl:stylesheet>

     

    The image now shows up fine (result!) but the introText is showing the whole text including markup as a string. Is there a way that I can render the markup as markup rather than encoded?

    I get this...

    <p><strong>Welcome to The Master Page</strong></p>

  • Michael Latouche 504 posts 819 karma points MVP 4x c-trib
    Jun 01, 2011 @ 13:25
    Michael Latouche
    1

    Hi Keith,

    I think you have to use the disable-output-escaping="yes" attribute on your xsl:value-of element. So this should do it:

     <h3><xsl:value-of select="$currentPage/introText" disable-output-escaping="yes"/></h3>

    Cheers,

    Michael

  • Keith Jackson 183 posts 552 karma points
    Jun 01, 2011 @ 13:50
    Keith Jackson
    0

    Thanks Michael,

    That was spot-on!

  • Michael Latouche 504 posts 819 karma points MVP 4x c-trib
    Jun 01, 2011 @ 13:57
    Michael Latouche
    0

    Great :-)

    Can you maybe mark the post as solution, so that others having the same issue can find it easier?

    Thx & Cheers!

    Michael.

  • Keith Jackson 183 posts 552 karma points
    Jun 01, 2011 @ 19:53
    Keith Jackson
    1

    I tried to High five you but I don't have enough Karma yet :o(

  • Michael Latouche 504 posts 819 karma points MVP 4x c-trib
    Jun 01, 2011 @ 23:32
    Michael Latouche
    0

    Yep, you need 70 karma to be able to High five...

    Thanks for the thought :-)

    Cheers,

    Michael.

Please Sign in or register to post replies

Write your reply to:

Draft