Why am I getting this error if the web form otherwise works properly?
I inserted an Xml control into a web form. The Xml document source is an XML file, with the structure below. The transform source is the XSLT file below. The XSLT file should use the data in the XML file to create a list of hyperlinks. This works when
I test it - the hyperlink shows up and has the correct URL when I hover over it. The rest of the web form also loads properly. But, I get this error:
This is apparently a known bug in VS 2013. I inserted the following into the web.config file and the error no longer occurs. I'm not sure what problem this fixes or how it fixes it, but so far it has worked.
Member
2 Points
15 Posts
XML control has runtime error: syntax error, unrecognized expression
Apr 26, 2015 11:54 PM|worsedeveloper|LINK
Why am I getting this error if the web form otherwise works properly?
I inserted an Xml control into a web form. The Xml document source is an XML file, with the structure below. The transform source is the XSLT file below. The XSLT file should use the data in the XML file to create a list of hyperlinks. This works when I test it - the hyperlink shows up and has the correct URL when I hover over it. The rest of the web form also loads properly. But, I get this error:
JavaScript runtime error: Syntax error, unrecognized expression: ?xml
I created an Xml control in the page source:
<asp:Xml ID="periodicalList" runat="server" DocumentSource="~/App_Data/periodicals.xml" TransformSource="~/stylesheet/periodicalDDL.xslt"></asp:Xml>
The xml file:
<periodicals>
<periodical name="test" pre="0" type="journal" id="000001" />
</periodicals>
The xslt file:
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<div>
<xsl:for-each select="periodicals/periodical">
<xsl:element name="a">
<xsl:attribute name="href">
<xsl:text>/db/</xsl:text>
<xsl:value-of select="@type" disable-output-escaping="yes"/>
<xsl:text>.aspx?id=</xsl:text>
<xsl:value-of select="@id" disable-output-escaping="yes"/>
</xsl:attribute>
<xsl:attribute name="target">
<xsl:text>_blank</xsl:text>
</xsl:attribute>
<xsl:value-of select="@name" disable-output-escaping="yes"/>
</xsl:element>
<br />
</xsl:for-each>
</div>
</xsl:template>
</xsl:stylesheet>
Member
2 Points
15 Posts
Re: XML control has runtime error: syntax error, unrecognized expression
Apr 27, 2015 12:57 PM|worsedeveloper|LINK
I tried adding the Xml control in the .cs code-behind, rather than in the .aspx. Same problem.
if (Page.IsPostBack == false)
{ Xml loadPubs = new Xml();
loadPubs.DocumentSource = Server.MapPath("~/App_Data/periodicals.xml");
loadPubs.TransformSource = Server.MapPath("~/stylesheet/periodicalDDL.xslt");
right.Controls.Add(loadPubs);
}
Star
8544 Points
1376 Posts
Re: XML control has runtime error: syntax error, unrecognized expression
Apr 28, 2015 03:47 AM|Edwin Guru Singh|LINK
As per this case, the following links which may guide you to resolve this issue :
1. Click here to get the sample code with step by step process about Creating a Web Page to Display XML Data
2. Click here to get the sample code with step by step process about Transforming XML with XSLT and ASP.NET
--
with regards,
Edwin
Edwin
Member
2 Points
15 Posts
Re: XML control has runtime error: syntax error, unrecognized expression
Apr 29, 2015 05:33 PM|worsedeveloper|LINK
This is apparently a known bug in VS 2013. I inserted the following into the web.config file and the error no longer occurs. I'm not sure what problem this fixes or how it fixes it, but so far it has worked.
<appSettings>
<add key="vs:EnableBrowserLink" value="false" />
</appSettings>