Paste xsl into XML file

I am trying to embed xsl in an XML file. The reason for this is the creation of a single file that can be transferred to different computers, which will prevent the xsl file from being moved.

The xsl file creates a table and captures the test step from xml and whether it passes or does not pass is pretty simple.
The problem I am facing is that xsl has javascript and its display when xml loads in IE.

When I load the xml file into IE, javascript is displayed above the table, and xml is displayed below the table.

Here is how my document is laid out:

<!DOCTYPE doc [ <!ATTLIST xsl:stylesheet id ID #REQUIRED> ]> <doc> <xsl:stylesheet id="4.1.0" version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:user="http://www.ni.com/TestStand" xmlns:vb_user="http://www.ni.com/TestStand/" > <xsl:template match="xsl:stylesheet" /> <xsl:text disable-output-escaping="yes"> <msxsl:script language="vbscript" implements-prefix="vb_user"> option explicit 'This function will return the localized decimal point for a decimal number Function GetLocalizedDecimalPoint () dim lDecPoint lDecPoint = Mid(CStr(1.1),2,1) GetLocalizedDecimalPoint = lDecPoint End Function </msxsl:script> <msxsl:script language="javascript" implements-prefix="user"><![CDATA[ // This style sheet will not show tables instead of graphs for arrays of values if // 1. TSGraph control is not installed on the machine // 2. Using the stylesheet in windows XP SP2. Security settings prevent stylesheets from creatign the GraphControl using scripting. // Refer to the TestStand Readme for more information. //more javascript functions //code to build table and insert data from the xml </xsl:stylesheet> <Reports> <Report Type='UUT' Title='UUT Report' Link='-1-2008-12-3-10-46-52-713' UUTResult='Failed' StepCount='51'> // rest of xml </Report> </Reports> </doc> 
+6
javascript xml internet-explorer xslt embed
source share
3 answers

Although the W3C XSLT Spec supports embedding the XSLT stylesheet in an XML document, it seems that IE and Firefox do not support this.

UPDATE . According to a comment by Robert Nishtroy, years later, in October 2014, this works in FireFox 33.

However, there is a good alternative: insert an XML document into the XSLT stylesheet .

The following is an example.

XSLT stylesheet containing an embedded XML document :

  <? xml-stylesheet type = "text / xsl" href = "myEmbedded.xml"?>
 <xsl: stylesheet version = "1.0"
  xmlns: xsl = "http://www.w3.org/1999/XSL/Transform">
  <xsl: output omit-xml-declaration = "yes" />
     <xsl: variable name = "vEmbDoc">
         <doc>
             <head> </head>
             <body>
                 <para id = "foo"> Hello I am foo </para>
             </body>
         </doc>
     </ xsl: variable>
     <xsl: template match = "para">
       <h1> <xsl: value-of select = "." /> </h1>
     </ xsl: template>
     <xsl: template match = "xsl: template" />
 </ xsl: stylesheet>

When a tis file opens in IE, the desired result is displayed by the browser:

Hi i foo

Note that you must include templates that ignore most XSLT instructions (in this case, we ignore any <xsl:template> just without the template body.

+11
source share

Style embedding is available for most browsers except IE. Find the description link and example in the wiring below.

IE6 / 7/8 does not support inline stylesheets by default.

You can use a workaround allowing IE to handle inline stylesheets from here:

http://www.biglist.com/lists/lists.mulberrytech.com/xsl-list/archives/201001/msg00390.html

0
source share

Since your stylesheet uses msxsl, the previous method for embedding style inserts for IE browsers should be good for you.

If you want style embedding that works for all browsers, you can use the style insert support technique for ALL browsers .

0
source share

All Articles