XSL and CDATA Help???

I am trying to include a menu.htm file into the xsl file.

I include in the xsl file where i need the menu.htm to show up.
<![CDATA[
<!-- The html is goes here -->
]]>

But for some reason when i load the xsl file, it shows up the html that i inserted between  the CDATA's tags is shown here. I noticed one thing when i viewed the View Source. The page has converted < to &lt; etc. A sample of the javascript code which i use in the CDATA is shown as follows:


&lt;script language="javascript"&gt;
function swapIt(hide, show) {
  hide.style.display = "none";
  show.style.display = "";
  }
&lt;/script&gt;

Is there any setting that i am missing.

Thanks
LVL 1
CIT_DEVAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
dualsoulConnect With a Mentor Commented:
CIT_DEV

this:
.................................................................................
<xsl:text disable-output-escaping="yes">
<![CDATA[
<script language="javascript">
function swapIt(hide, show) {
  hide.style.display = "none";
  show.style.display = "";
  }
</script>
<link rel="stylesheet" href="full.css">
<script language="JavaScript" src="includes/Common.js" type="text/javascript"></script>
<table border="0" cellspacing="0" cellpadding="0" width="175">
  <tr>
    <td valign="top"><IMG height=1 src="images/spacers.gif" width=175><br>
      <table width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td width="14" background="images/gadget-header_bg.gif"><IMG height=18 src="images/gadget-header_corner.gif"

width=14></td>
         
          <td bgcolor="#9cbece" align="right" nowrap valign="bottom" background="images/gadget-header_bg2.gif">&nbsp;</td>
          <td background="images/gadget-header_bg.gif" align="right" valign="top"><IMG height=18 src="images/right-edge.gif"

width=1></td>
        </tr>
      </table>
     <!--2004 -->
      <table border="0" cellspacing="0" cellpadding="0" width="175" class="greyborder">
 
        <tr>
         
          <td id=onetable style="DISPLAY: none" align="left"
          valign="top">
            <table border="0" cellspacing="0" cellpadding="2" width="100%">
              <tr>
                <td class="newsboxheader" align="left" valign="top" colspan="2"><b><IMG style="CURSOR: hand"

onclick=swapIt(onetop,onetable) height=5 alt=More src="images/spacers.gif" width=5 ></b><span

class="gadgetheaderwhite"><b><IMG style="CURSOR: hand" onclick=swapIt(onetop,onetable) height=1 alt=More

src="images/spacers.gif" width=140 ></b><br>
                  </span><span class="orangetxt"><b>2004</b></span></td>
                <td class="newsboxheader" valign="top" align="right"><b><IMG style="CURSOR: hand"

onclick=swapIt(onetable,onetop) height=15 alt=Less src="images/buttonarrow_up-b.gif" width=19 ></b></td>
              </tr>


                    <!--PRINT THE VALUES FOR EACH MONTH -->
                    <tr align="left" valign="top">
                         <td class="newsboxyellow" colspan="2"><CENTER><A class=smalltext

href="questionsMonth.asp?yy=04&mm=01">January</A></td>
                </tr>
                <tr align="left" valign="top">
                         <td class="newsboxyellow" colspan="2"><CENTER><A class=smalltext

href="questionsMonth.asp?yy=04&mm=02">February</A></td>
                </tr>
                <tr align="left" valign="top">
                         <td class="newsboxyellow" colspan="2"><CENTER><A class=smalltext

href="questionsMonth.asp?yy=04&mm=03">March</A></td>
                </tr>
                <tr align="left" valign="top">
                         <td class="newsboxyellow" colspan="2"><CENTER><A class=smalltext

href="questionsMonth.asp?yy=04&mm=04">April</A></td>
                </tr>
                <tr align="left" valign="top">
                         <td class="newsboxyellow" colspan="2"><CENTER><A class=smalltext

href="questionsMonth.asp?yy=04&mm=05">May</A></td>
                </tr>
                <tr align="left" valign="top">
                         <td class="newsboxyellow" colspan="2"><CENTER><A class=smalltext

href="questionsMonth.asp?yy=04&mm=06">June</A></td>
                </tr>
                <tr align="left" valign="top">
                         <td class="newsboxyellow" colspan="2"><CENTER><A class=smalltext

href="questionsMonth.asp?yy=04&mm=07">July</A></td>
                </tr>
                <tr align="left" valign="top">
                         <td class="newsboxyellow" colspan="2"><CENTER><A class=smalltext

href="questionsMonth.asp?yy=04&mm=08">August</A></td>
                </tr>
                <tr align="left" valign="top">
                         <td class="newsboxyellow" colspan="2"><CENTER><A class=smalltext

href="questionsMonth.asp?yy=04&mm=09">September</A></td>
                </tr>
                <tr align="left" valign="top">
                         <td class="newsboxyellow" colspan="2"><CENTER><A class=smalltext

href="questionsMonth.asp?yy=04&mm=10">October</A></td>
                </tr>
                <tr align="left" valign="top">
                         <td class="newsboxyellow" colspan="2"><CENTER><A class=smalltext

href="questionsMonth.asp?yy=04&mm=11">November</A></td>
                </tr>
                <tr align="left" valign="top">
                         <td class="newsboxyellow" colspan="2"><CENTER><A class=smalltext

href="questionsMonth.asp?yy=04&mm=12">December</A></td>
                </tr>
           </table>
      </table>
     <!--2003 -->
   
     <!--2002 -->
     
    </td>
  </tr>
  <tr>
    <td>&nbsp;</td>
  </tr>
</table>
                                                       
]]>
</xsl:text>
.................................................................................

outputs all inside CDATA section as is. No any replacement of < to &lt; and so on.
if it still doesn't work, please post full XSLT you are trying to make work, so we can check it.
0
 
dfiala13Commented:
put the CDATA inside <xsl:text disable-out-escaping="yes"> </xsl:text>
0
 
dualsoulCommented:
try this approach:

<xsl:text disable-output-escaping="yes">
<![CDATA[
   <script language="javascript">
      function swapIt(hide, show) {
              hide.style.display = "none";
              show.style.display = "";
        }
    </script>
]]>
</xsl:text>

Hope it helps you .
0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
rdcproCommented:
This is how I do it:

<script language="javascript"><![CDATA[
function swapIt(hide, show) {
  hide.style.display = "none";
  show.style.display = "";
  }
]]></script>


If you need to insert values from the transformation into the script code, you have to "open a hole" in the CDATA:

<script language="javascript"><![CDATA[
function swapIt(hide, show) {
  var myString = "]]><xsl:value-of select="path/to/data"/><![CDATA[";
  hide.style.display = "none";
  show.style.display = "";
  }
]]></script>

If this doesn't answer your question, post more of the XSLT as it is coded, so I can see what you're trying to do.

Regards,
Mike Sharp
0
 
dualsoulCommented:
whee...i'm only second ;)
0
 
CIT_DEVAuthor Commented:
ArchiveMenu.htm


<script language="javascript">
function swapIt(hide, show) {
  hide.style.display = "none";
  show.style.display = "";
  }
</script>
<link rel="stylesheet" href="full.css">
<script language="JavaScript" src="includes/Common.js" type="text/javascript"></script>
<table border="0" cellspacing="0" cellpadding="0" width="175">
  <tr>
    <td valign="top"><IMG height=1 src="images/spacers.gif" width=175><br>
      <table width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td width="14" background="images/gadget-header_bg.gif"><IMG height=18 src="images/gadget-header_corner.gif"

width=14></td>
         
          <td bgcolor="#9cbece" align="right" nowrap valign="bottom" background="images/gadget-header_bg2.gif">&nbsp;</td>
          <td background="images/gadget-header_bg.gif" align="right" valign="top"><IMG height=18 src="images/right-edge.gif"

width=1></td>
        </tr>
      </table>
     <!--2004 -->
      <table border="0" cellspacing="0" cellpadding="0" width="175" class="greyborder">
 
        <tr>
            
          <td id=onetable style="DISPLAY: none" align="left"
          valign="top">
            <table border="0" cellspacing="0" cellpadding="2" width="100%">
              <tr>
                <td class="newsboxheader" align="left" valign="top" colspan="2"><b><IMG style="CURSOR: hand"

onclick=swapIt(onetop,onetable) height=5 alt=More src="images/spacers.gif" width=5 ></b><span

class="gadgetheaderwhite"><b><IMG style="CURSOR: hand" onclick=swapIt(onetop,onetable) height=1 alt=More

src="images/spacers.gif" width=140 ></b><br>
                  </span><span class="orangetxt"><b>2004</b></span></td>
                <td class="newsboxheader" valign="top" align="right"><b><IMG style="CURSOR: hand"

onclick=swapIt(onetable,onetop) height=15 alt=Less src="images/buttonarrow_up-b.gif" width=19 ></b></td>
              </tr>


                        <!--PRINT THE VALUES FOR EACH MONTH -->
                        <tr align="left" valign="top">
                              <td class="newsboxyellow" colspan="2"><CENTER><A class=smalltext

href="questionsMonth.asp?yy=04&mm=01">January</A></td>
                </tr>
                <tr align="left" valign="top">
                              <td class="newsboxyellow" colspan="2"><CENTER><A class=smalltext

href="questionsMonth.asp?yy=04&mm=02">February</A></td>
                </tr>
                <tr align="left" valign="top">
                              <td class="newsboxyellow" colspan="2"><CENTER><A class=smalltext

href="questionsMonth.asp?yy=04&mm=03">March</A></td>
                </tr>
                <tr align="left" valign="top">
                              <td class="newsboxyellow" colspan="2"><CENTER><A class=smalltext

href="questionsMonth.asp?yy=04&mm=04">April</A></td>
                </tr>
                <tr align="left" valign="top">
                              <td class="newsboxyellow" colspan="2"><CENTER><A class=smalltext

href="questionsMonth.asp?yy=04&mm=05">May</A></td>
                </tr>
                <tr align="left" valign="top">
                              <td class="newsboxyellow" colspan="2"><CENTER><A class=smalltext

href="questionsMonth.asp?yy=04&mm=06">June</A></td>
                </tr>
                <tr align="left" valign="top">
                              <td class="newsboxyellow" colspan="2"><CENTER><A class=smalltext

href="questionsMonth.asp?yy=04&mm=07">July</A></td>
                </tr>
                <tr align="left" valign="top">
                              <td class="newsboxyellow" colspan="2"><CENTER><A class=smalltext

href="questionsMonth.asp?yy=04&mm=08">August</A></td>
                </tr>
                <tr align="left" valign="top">
                              <td class="newsboxyellow" colspan="2"><CENTER><A class=smalltext

href="questionsMonth.asp?yy=04&mm=09">September</A></td>
                </tr>
                <tr align="left" valign="top">
                              <td class="newsboxyellow" colspan="2"><CENTER><A class=smalltext

href="questionsMonth.asp?yy=04&mm=10">October</A></td>
                </tr>
                <tr align="left" valign="top">
                              <td class="newsboxyellow" colspan="2"><CENTER><A class=smalltext

href="questionsMonth.asp?yy=04&mm=11">November</A></td>
                </tr>
                <tr align="left" valign="top">
                              <td class="newsboxyellow" colspan="2"><CENTER><A class=smalltext

href="questionsMonth.asp?yy=04&mm=12">December</A></td>
                </tr>
            </table>
      </table>
     <!--2003 -->
   
     <!--2002 -->
     
    </td>
  </tr>
  <tr>
    <td>&nbsp;</td>
  </tr>
</table>

*******************************************
XSL FILE
*******************************************

<?xml version="1.0" encoding="UTF-8"  ?>

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                                                         xmlns:msxsl="urn:schemas-microsoft-com:xslt"
                                                          xmlns:date="http://www.test.com/corporate-it"
                                                          extension-element-prefixes="date"
                                                          exclude-result-prefixes="date msxsl">

      <xsl:import href="../../common/_xsl/date_library.xslt"/>
                                                        
      <xsl:output method="html" version="1.0" indent="yes" encoding="UTF-8" />


      <xsl:template match="root">
<html>
      <head>
            <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
            <title>ITMT Questions &amp; Answers</title>
            <script language="javascript">                        
                        function showHideAnswer(strID) {
                              document.all(strID).style.display = (document.all(strID).style.display == "none") ? "inline" : "none"
                              window.event.srcElement.innerText = (document.all(strID).style.display == "none") ? "Show Answer" : "Hide Answer"
                              return false
                        }      
                  function printPage() {
                    if (window.print)
                      window.print()
                    else
                      alert("Sorry, your browser doesn't support this feature.");
                  }
            </script>      
            <link rel="stylesheet" href="styles.css" type="text/css"/>
            
      </head>

      <body link="blue" alink="blue" vlink="blue" topmargin="0" leftmargin="0">
<table width="185" height="100%" cellpadding="0" cellspacing="0" border="0">
                        <tr>
                              <td width="175" height="100%">
                                    <table bgcolor="FFF8DE" width="175" height="550" cellpadding="0" cellspacing="0" border="0">
                                          <tr>
                                                <td colspan="2" width="175" height="23" valign="top"><img src="images/spacer.gif" width="175" height="23" alt="" border="0"/></td>
                                          </tr>
                                          <tr>
                                                <td width="5%" align="left" valign="top" height="100%"></td>
                                                <td valign="top">      
                                                      <table id="tblHomePageNavigation" cellpadding="2" border="0" width="100%" cellspacing="0">
                                                            <tr>
                                                                  <td>
                                                                  <!--START OF THE ARCHIVE MENU LIST -->
                                                                  
                                                                                                                                    
                                                                        <![CDATA[
                                                                  
                                                                        ]]>

                                                                  <!--END OF THE ARCHIVE LIST -->
                                                                  </td>
                                                            </tr>
                                                            <tr>
                                                                  <td><a href="question_sub.asp?
0
 
dfiala13Commented:
<!--START OF THE ARCHIVE MENU LIST -->
<xsl:text disable-out-escaping="yes"> <![CDATA[  


HTML here



 ]]>
</xsl:text>
<!--END OF THE ARCHIVE LIST -->

Of course, I think I'd just leave the html in a separate file and use an include there instead.

 <!--START OF THE ARCHIVE MENU LIST -->
<!-- #include virtual="/ArchiveMenu.htm" -->

<!--END OF THE ARCHIVE LIST -->
0
 
CIT_DEVAuthor Commented:
The include solution fails.
<!-- #include virtual="/ArchiveMenu.htm" -->

The Embedded html between the <![CDATA[  ]]> also fails. The information between the CDATA is being transformed with special characters (ie < get converted to &lt;  etc) even after escaping is diabled.


0
 
CIT_DEVAuthor Commented:
I am getting an error if i use <xsl:text disable-output-escaping="yes">. The XML is not well formated. If i change this to <xsl:text disable-output-escaping="yes"/> then the xml is well formated,
Should i be using <xsl:text disable-output-escaping="yes"/>
0
 
CIT_DEVAuthor Commented:
I used
<xsl:text disable-output-escaping="yes">
<![CDATA[

INSERT TEXT HERE
 ]]></xsl:text>

I finally got it to work. I forgot the end tag "</xsl:text> "


0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.