Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

XSL and CDATA Help???

Posted on 2004-04-06
10
Medium Priority
?
728 Views
Last Modified: 2008-03-06
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
0
Comment
Question by:CIT_DEV
  • 4
  • 3
  • 2
  • +1
10 Comments
 
LVL 12

Expert Comment

by:dfiala13
ID: 10769470
put the CDATA inside <xsl:text disable-out-escaping="yes"> </xsl:text>
0
 
LVL 15

Expert Comment

by:dualsoul
ID: 10769493
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
 
LVL 26

Expert Comment

by:rdcpro
ID: 10769498
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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 15

Expert Comment

by:dualsoul
ID: 10769501
whee...i'm only second ;)
0
 
LVL 1

Author Comment

by:CIT_DEV
ID: 10769650
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
 
LVL 12

Expert Comment

by:dfiala13
ID: 10771890
<!--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
 
LVL 1

Author Comment

by:CIT_DEV
ID: 10772028
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
 
LVL 15

Accepted Solution

by:
dualsoul earned 750 total points
ID: 10772415
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
 
LVL 1

Author Comment

by:CIT_DEV
ID: 10775010
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
 
LVL 1

Author Comment

by:CIT_DEV
ID: 10775083
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

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The Client Need Led Us to RSS I recently had an investment company ask me how they might notify their constituents about their newsworthy publications.  Probably you would think "Facebook" or "Twitter" but this is an interesting client.  Their cons…
Create a Windows 10 custom Image with custom task bar and custom start menu using XML for deployment.
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
Suggested Courses

927 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question