locked
<xsl:text is not loading in browser RRS feed

  • Question

  • <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet 
    version="2.0" 
    exclude-result-prefixes="x d xsl msxsl cmswrt"
    xmlns:x="http://www.w3.org/2001/XMLSchema" 
    xmlns:d="http://schemas.microsoft.com/sharepoint/dsp" 
    xmlns:cmswrt="http://schemas.microsoft.com/WebParts/v3/Publishing/runtime"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:msxsl="urn:schemas-microsoft-com:xslt"
    xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime">
    <xsl:output method="xml" version="1.0" media-type="text/html" omit-xml-declaration="yes" indent="yes"/>


    <xsl:template match="/">
    <xsl:call-template name="SCCalendarTemplate"/>
    <!--<xmp><xsl:copy-of select="*"/></xmp>-->
    </xsl:template>
    <xsl:template name="SCCalendarTemplate">
    <xsl:variable name="Results" select="All_Results/Result" />
    <xsl:text disable-output-escaping="yes"> 
    <![CDATA[

    <style type="text/css">
    table.sc-calendar-table {
    border-collapse:collapse;

    width:100%;
    }
    table.sc-calendar-table thead tr {
    background-color:#ccc;
    text-align:left;
    }

    </style>

    ]]>

    </xsl:text>

     <![CDATA[ .... ]]> section is not loading in browser. I have written style and javascript inside CDATA section to execute. The .xsl file is referenced inside SharePoint 2010 core search result webpart. This issue has suddenly came into picture, where as it was working perfect before.
    Saturday, July 11, 2020 7:40 PM

All replies

  • Hi Shilabhadra,

    When adding CSS Style into xsl data, it's necessary to add with <html></html> tag together, here is a demo for your reference:

    <?xml version='1.0'?>
    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
    
    <xsl:template match="book">
        <HTML>
    <HEAD>
                <TITLE>Book Info</TITLE>
            <STYLE>
                    H1 {font-family: Arial,Univers,sans-serif;
                        font-size: 36pt }
            </STYLE>
        </HEAD>
        <BODY><xsl:apply-templates/></BODY>
        </HTML>
    </xsl:template>
    
    <xsl:template match="book_title">
        <H1><xsl:value-of select="."/></H1>
    </xsl:template>
    
    </xsl:stylesheet>

    Reference:

    Incorporating <STYLE> Elements into an XSLT File

    Thanks

    Best Regards


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    SharePoint Server 2019 has been released, you can click here to download it.
    Click here to learn new features. Visit the dedicated forum to share, explore and talk to experts about SharePoint Server 2019.

    Monday, July 13, 2020 6:25 AM
  • Sorry, it does not helped me.

    Below is my .xsl file :

    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet 
    version="1.0" 
    exclude-result-prefixes="x d xsl msxsl cmswrt"
    xmlns:x="http://www.w3.org/2001/XMLSchema" 
    xmlns:d="http://schemas.microsoft.com/sharepoint/dsp" 
    xmlns:cmswrt="http://schemas.microsoft.com/WebParts/v3/Publishing/runtime"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:msxsl="urn:schemas-microsoft-com:xslt"
    xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime">
    <xsl:output method="xml" version="1.0" media-type="text/html" omit-xml-declaration="yes" indent="yes"/>

    <xsl:template match="/">
    <xsl:call-template name="SCCalendarTemplate"/>
    <!--<xmp><xsl:copy-of select="*"/></xmp>-->
    </xsl:template>
    <xsl:template name="SCCalendarTemplate">
    <xsl:variable name="Results" select="All_Results/Result" />
    <xsl:text disable-output-escaping="yes"> 
    <![CDATA[
     
    <style type="text/css">
    ------
    -----
    </style>
    <script type="text/javascript">
    -------
    -------
    </script>
    ]]>
    </xsl:text>

    <div>Design goes here</div>

    </xsl:template>
    </xsl:stylesheet>

    This .xsl is called inside sharepoint 2010 search core result webpart. HTML design is loading in browser, but skipping style and javascript.

    [FYI: it was fine before and working in other environment.]


    Monday, July 13, 2020 11:29 AM
  • Hi Shilabhadra,

    If it was working fine in the past, then did you change something in your side ?

    I suggest you can create a new page and add search result web part and edit the web part xsl data to see if it's working.

    I assume maybe there are some browser cache affected it.

    Thanks

    Best Regards


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    SharePoint Server 2019 has been released, you can click here to download it.
    Click here to learn new features. Visit the dedicated forum to share, explore and talk to experts about SharePoint Server 2019.

    Monday, July 13, 2020 11:49 AM
  • Hi Jerry, thanks for your response.

    I have tried creating a new page with search result webpart, still no luck. No changes has been done in the settings, properties etc..

    Monday, July 13, 2020 2:38 PM
  • Hi Shiabhadra,

    Try to clear the browser cache and then check if the CSS loaed in the page using Developer Tool (F12).

    If the issue still existed, I suggest you can add the CSS/JavaScript using the Content Editor Web Part as a workaround.

    Thanks

    Best Regards


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    SharePoint Server 2019 has been released, you can click here to download it.
    Click here to learn new features. Visit the dedicated forum to share, explore and talk to experts about SharePoint Server 2019.

    Tuesday, July 14, 2020 12:49 AM
  • Hi Jerry,

    Thanks for your suggestion.

    CSS is not loading in developer tool(F12).  Yes, CSS is working as expected in CEWP, but Javascript functions are not calling from CEWP.

    Tuesday, July 14, 2020 4:47 AM
  • Hi Shiabhadra,

    For JavaScript is not calling from CEWP, you may need to set break point in Developer Tool to see if there is any error occurred. 

    I can't see your environment, but it should be a debug need right now.

    Thanks

    Best Regards


    "SharePoint" forums will be migrating to a new home on Microsoft Q&A !
    We invite you to post new questions in the "SharePoint" forums' new home on Microsoft Q&A !

    Tuesday, July 14, 2020 5:19 AM
  • In this case, the script in CEWP will not get the properties(Managed properties) configured inside search webpart configuration. No value is showing in webpart now.
    Tuesday, July 14, 2020 7:14 PM