xsl-list
[Top] [All Lists]

Re: [xsl] Best approach for adding Java Script?

2009-02-09 11:28:51

On Feb 9, 2009, at 11:20 AM, David Carlisle wrote:


1.  To add a comment (AS below lt IE7)

I just replied saying to use xsl:comment but I see you don't want a
comment you want

   <![endif]-->


which isn't a comment it;s a syntax error (not that there is any point
arguing that case with IE:-) XSLt can not generate that without using
disable-output-escaping

<xsl:text disable-output-escaping="yes">&lt;![endif]--></xsl:text>

Here is an example from one of my projects:


<xsl:template match="s:content" mode="tab">
<xsl:if test="not(@id='start-1.1.1') and @onnav='1' and @generate='1'">
    <xsl:variable name="href">
      <xsl:apply-templates select="." mode="get_page_href"/>
    </xsl:variable>
    <li id="{translate(@id, '.', '')}">
      <a href="{$href}">
        <xsl:if test="@id=$lsb_focus_nodeset/@id">
          <xsl:attribute name="class">selected</xsl:attribute>
        </xsl:if>
        <xsl:value-of select="@label"/>
        <xsl:comment><![CDATA[[if IE 7]><!]]></xsl:comment>
      </a>
      <xsl:comment><![CDATA[<![endif]]]></xsl:comment>
<xsl:comment><![CDATA[[if lte IE 6]><table><tr><td><! [endif]]]></xsl:comment> <xsl:comment><![CDATA[[if lte IE 6]></td></tr></table></a><! [endif]]]></xsl:comment>
    </li>
  </xsl:if>
</xsl:template>

<xsl:template match="s:folder" mode="tab">
  <xsl:if test="@onnav='1' and @generate='1'">
    <xsl:variable name="href">
      <xsl:apply-templates select="." mode="get_page_href"/>
    </xsl:variable>
    <li id="{translate(@id, '.', '')}">
      <a href="{$href}">
<xsl:if test="descendant-or-self::*[(_at_)id=$lsb_focus_nodeset/ @id]">
          <xsl:attribute name="class">selected</xsl:attribute>
        </xsl:if>
        <xsl:value-of select="@label"/>
        <xsl:comment><![CDATA[[if IE 7]><!]]></xsl:comment>
      </a>
      <xsl:comment><![CDATA[<![endif]]]></xsl:comment>
<xsl:comment><![CDATA[[if lte IE 6]><table><tr><td><! [endif]]]></xsl:comment>
      <ul>
        <xsl:apply-templates mode="tab-item"/>
      </ul>
<xsl:comment><![CDATA[[if lte IE 6]></td></tr></table></a><! [endif]]]></xsl:comment>
    </li>
  </xsl:if>
</xsl:template>

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--