Copied to clipboard

Flag this post as spam?

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


  • Rachel Skuse 88 posts 118 karma points
    Nov 15, 2011 @ 11:35
    Rachel Skuse
    0

    XSLT is working but not displaying in web page?!

    Hi,

    I've created an XSLT file that is working using the visualiser but when I go to the web page it is not displaying!

    However, if I view the source then the correct content is there?!

    I've tried removing all styles applied but still the same thing.

    Has anyone come across this before?!

    Thanks,

    Rachel

  • Chriztian Steinmeier 2800 posts 8791 karma points MVP 8x admin c-trib
    Nov 15, 2011 @ 11:59
    Chriztian Steinmeier
    0

    Hi Rachel,

    Most likely this happens in Internet Explorer when a tag gets closed in the XHTML way like this: <script src="xyz.js"/> or <div/>

    There are ways to fix this - the easiest (with no side-effects) is to throw a <xsl:comment/> instruction inside, e.g.:

    <script src="xyz.js"><xsl:comment/></script>

    /Chriztian

  • Rachel Skuse 88 posts 118 karma points
    Nov 15, 2011 @ 13:18
    Rachel Skuse
    0

    Thank you for your response Chriztian but I am experiencing the problem in FF as well.

    I actually think that the issue may lie in my code because I am trying to update from the old to new schema.

    Is the following correct? Or am I missing something?

    <xsl:variable name="genMethod" select="genericMethod"/>

      <xsl:if test="$genMethod != ''">
      <xsl:value-of select="$genMethod" disable-output-escaping="yes" />
      </xsl:if>

    /Rachel

  • Chriztian Steinmeier 2800 posts 8791 karma points MVP 8x admin c-trib
    Nov 15, 2011 @ 13:32
    Chriztian Steinmeier
    0

    Hi Rachel,

    I'm pretty sure Firefox does that as well :-)

    You say that view-source reveals the code being there - and it's not CSS-related, so... 

    Nothing wrong with your code - though you could do the same with a simple normalize-space() test:

    <xsl:value-of select="genericMethod[normalize-space()]" disable-output-escaping="yes" />

    Unless you need a wrapper in the case of there being something in the genericMethod property:

    <xsl:if test="normalize-space(genericMethod)">
       <p>
          <xsl:value-of select="genericMethod" disable-output-escaping="yes" />
       </p>
    </xsl:if>

    /Chriztian 

  • Rachel Skuse 88 posts 118 karma points
    Nov 15, 2011 @ 15:32
    Rachel Skuse
    0

    Hi Chriztian,

    I tried using your above example but it made no difference :(

    This is my full code...

    <xsl:template match="/">

    <!-- start writing XSLT -->

      <ul id="accordion">
        <xsl:for-each select="$currentPage/AccordianItemRecipe">
        <xsl:variable name="itemImage" select="recipeImage"/>

          <li class="acItemTitle">
            <a href="#" class="acItemTitleA">
              <span class="acItemSpan"><xsl:value-of select="@nodeName" /></span>
              <span class="acItemTitleASpan">
                Read more
              </span>
              <span class="clear"><xsl:comment>1</xsl:comment></span>
            </a>
            <div class="acItemContent">

    <!-- Recipe Content here -->

    <div class="recipecontainer">

             <xsl:value-of select="recipeName" disable-output-escaping="yes" />&nbsp;/serves&nbsp;<xsl:value-of select="recipeServes" disable-output-escaping="yes" />
             <xsl:value-of select="recipeIntro" disable-output-escaping="yes" /><br />
             <p>
                 <xsl:if test="recipeImage != ''">
                    <img src="{$itemImage}" class="recipeImage" />
                </xsl:if>
             </p>

        <div id="ingredients">
            <span class="recipebold">Ingredients</span>
            <div class="columns">
                <xsl:if test="recipeSubHeading1 != ''">
                  <strong><xsl:value-of select="recipeSubHeading1" disable-output-escaping="yes" /></strong><br/>
                </xsl:if>
                <xsl:if test="recipeIngredients1 != ''">
                    <xsl:value-of select="recipeIngredients1" disable-output-escaping="yes" /><br/>
                </xsl:if>
                <xsl:if test="recipeSubHeading2 != ''">
                  <strong><xsl:value-of select="recipeSubHeading2" disable-output-escaping="yes" /></strong><br/>
                </xsl:if>
                <xsl:if test="recipeIngredients2 != ''">
                  <xsl:value-of select="recipeIngredients2" disable-output-escaping="yes" /><br/>
                </xsl:if>
                <xsl:if test="recipeSubHeading3 != ''">
                  <strong><xsl:value-of select="recipeSubHeading3" disable-output-escaping="yes" /></strong><br/>
                </xsl:if>
                <xsl:if test="recipeIngredients3 != ''">
                    <xsl:value-of select="recipeIngredients3" disable-output-escaping="yes" />
                </xsl:if>
            </div>
        </div>
        <div class="clear">
        </div>
        <br />
        <div id="method">
            <span class="recipebold">Method</span>
            <p></p>
            <p>
          <xsl:if test="genericRecipeMethod != ''">
          <xsl:value-of select="genericRecipeMethod" disable-output-escaping="yes" />
          </xsl:if>
          <xsl:if test="ovenAGAMethod2 != ''">
          <xsl:value-of select="ovenAGAMethod2" disable-output-escaping="yes" />
          </xsl:if>
          <xsl:if test="ovenAGAMethod34 != ''">
          <xsl:value-of select="ovenAGAMethod34" disable-output-escaping="yes" />
          </xsl:if>
          <xsl:if test="ovenAGAMethod234 != ''">
          <xsl:value-of select="ovenAGAMethod234" disable-output-escaping="yes" />
          </xsl:if>
            </p>
        </div>
        
          <xsl:if test="recipeNotes != ''">
        <div class="recipeNotes">
            <h2>Notes</h2>
              <p><xsl:value-of select="recipeNotes" disable-output-escaping="yes" /></p>
        </div>
      </xsl:if>
    </div>


    <!-- End Recipe Content -->
       
      </div>
            <div class="clear"><xsl:comment>1</xsl:comment></div>
          </li>
        </xsl:for-each>
      </ul>
    </xsl:template>

    The recipe image and ingredients are displaying but everything in <div id="method"> is not - it's really puzzling me as I can't see any difference in my code?!

    /Rachel

  • Chriztian Steinmeier 2800 posts 8791 karma points MVP 8x admin c-trib
    Nov 15, 2011 @ 15:40
    Chriztian Steinmeier
    1

    Hi Rachel,

    The very first <p> element in that <div> will come out as <p/> in the rendered HTML - so this is where you need to just put a comment in:

    <p><xsl:comment/></p>

    And just to make sure that in the case of none of the following "genericRecipeMethod", "ovenAGAMethod2", "ovenAGAMethod34" or "ovenAGAMethod234" have content, put a comment inside that <p> too, e.g. just before the closing </p>.

    There's also a couple of clearing <div>'s you should make sure to safeguard with a <xsl:comment/> inside. 

    /Chriztian

  • Rachel Skuse 88 posts 118 karma points
    Nov 15, 2011 @ 16:00
    Rachel Skuse
    0

    Ah, I finally found the problem - thank you so much for you help!

    I just needed to replace

    <div class="clear"></div> 

    with

    <div class="clear"><xsl:comment /></div>

    /Rachel :)

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies