Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

xslt in ASP.NET

Tags:

c#

xml

asp.net

xslt

I know very little about ASP.NET, have to fix some broken layout in some ASP.NET webforms though. The following code:

<head id="Head1" runat="server">
...
<xml id="dataList_xsl">
<xsl:transform version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:extObject="urn:extObject">
<xsl:output method="html" />
<xsl:template match="/">
    <table unselectable="on" id="my_table_mains" cellspacing="0" cellpadding="3" class="dataListTable view" style="width: 100%;"> 
        <tr unselectable="on">
            COLUMNS_DEFINITION
        </tr>
...

should display NOTHING in the case of no match, and so it was in Internet Explorer 8, however it displays the "COLUMNS_DEFINITION" in the newer versions of IE. How can I fix it?
I get a validation error on the tag - Element 'xml' not supported, btw.

like image 900
Greg Avatar asked Nov 15 '13 15:11

Greg


People also ask

What is XSLT in asp net?

XSL (eXtensible Stylesheet Language) is a styling language for XML. XSLT stands for XSL Transformations. This tutorial will teach you how to use XSLT to transform XML documents into other formats (like transforming XML into HTML).

What is XSLT used for?

XSLT is used to transform XML documents into XHTML documents, or into other XML documents.

What is difference between XML and XSLT?

XML specifies the structure of a document; it does not specify how to display it. XSLT is a language for transforming XML documents—for example, into a human-readable format such as HTML. ATG products provide XSLT and JSP templates that transform XML documents for display.

What is XSL vs XSLT?

XSLT is designed to be used as part of XSL. In addition to XSLT, XSL includes an XML vocabulary for specifying formatting. XSL specifies the styling of an XML document by using XSLT to describe how the document is transformed into another XML document that uses the formatting vocabulary.


1 Answers

I don't think it has anything to do with ASP.NET. IE (Internet Explorer) used to support an extension to HTML, so called XML data islands, where you put XML data or stylesheets into a new, proprietary element to HTML, the xml element. If you want to continue to use that element and have newer versions of IE support it then you need to make sure you set the x-ua-compatible to IE 8, either by sending the HTTP header or by including a meta:

<head>
  <meta http-equiv="x-ua-compatible" content="IE=8">

See http://msdn.microsoft.com/en-us/library/jj676915%28v=vs.85%29.aspx for details.

I wrote two test cases, with http://home.arcor.de/martin.honnen/html/test2013112001.html IE 10 on Windows 8 shows the content of the XSLT inside the xml element as the HTML 5 parser it has moves the xml stuff in the head section to the body (press F12 to see the parse tree) while with http://home.arcor.de/martin.honnen/html/test2013112002.html and the meta enforcement to use IE 8 the xml is recognized as an XML data island (press F12 to see parse tree) and does not output content inside of the XML data island.

Greg, if you still have problems then check that your ASP.NET is not sending a different HTTP x-ua-compatible header that might override the meta.

Here is a link: http://msdn.microsoft.com/en-us/library/ie/hh801224%28v=vs.85%29.aspx. It suggests a slightly different meta <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE9">, in the end it amounts to ensure that the legacy parser is used that recognizes an xml element as an XML data island.

like image 167
Martin Honnen Avatar answered Oct 02 '22 08:10

Martin Honnen