CAUSE
This behavior occurs when both of the following conditions are true:
- You are opening an XML file or an XML file with an Extensible Stylesheet Language (XSL) style sheet.
-and- - The XML file or XSL style sheet has a line feed or carriage return character inside a <?XML?> header or between an opening (<xsl>) and closing (</xsl>) header.
Example 1: Line Feed or Carriage Return in XML File
For example, an XML file containing the following header exhibits the behavior described in the "Symptoms" section of this article:
<?xml
version="1.0"?>
<a>
1
</a>
Example 2: Line Feed or Carriage Return in XSL File
The following XML file has an XSL style sheet called "employees.xsl":
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="employees.xsl"?>
<dataroot xmlns:od="urn:schemas-microsoft-com:officedata" xmlns:xsi="http://www.w3.org/2000/10/XMLSchema-instance" xsi:noNamespaceSchemaLocation="employees.xsd">
<Employees>
<EmployeeID>1</EmployeeID>
<LastName>Davolio</LastName>
<FirstName>Nancy</FirstName>
</Employees>
</dataroot>
If "employees.xsl" contains the following text, the following behavior is exhibited when you open the XML file and specify to apply the style sheet:
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl" language="vbscript">
<xsl:template match="/">
<xsl:pi name="xml"> version="1.0"
</xsl:pi>
<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet" xmlns:n1="urn:schemas-microsoft-com:office:spreadsheet">
<Worksheet n1:Name="Employees">
</Worksheet>
</Workbook>
</xsl:template>
</xsl:stylesheet>
NOTE: The line that begins with
<xsl:pi> has a carriage return before the
</xsl:pi> header.
RESOLUTION
To resolve this issue, edit the XML files and XSL style sheets to remove all carriage-return and line-feed characters from between the starting and ending headers. The preceding examples work correctly if changed to the following:
Example 1
<?xml version="1.0"?>
<a>
1
</a>
Example 2
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl" language="vbscript">
<xsl:template match="/">
<xsl:pi name="xml"> version="1.0" </xsl:pi>
<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet" xmlns:n1="urn:schemas-microsoft-com:office:spreadsheet">
<Worksheet n1:Name="Employees">
</Worksheet>
</Workbook>
</xsl:template>
</xsl:stylesheet>