1

I am trying to use the XML Viewer web part in SharePoint 2010. Using the this XML

<?xml version="1.0" encoding="UTF-8"?>
<STOCKQUOTE ROWCOUNT='1'>
  <RESULT>
    <ROW>
      <COMPANYNAME>Test Company Name</COMPANYNAME>
    </ROW>
  </RESULT>
</STOCKQUOTE>

and this XSL

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:template match="/">
        <h2><xsl:value-of select="STOCKQUOTE/RESULT/ROW/COMPANYNAME" /></h2>
  </xsl:template>
</xsl:stylesheet>

in the XML editor and XSL editor of the web part options menu, when I click apply I get the error 'Failed to apply XSLT to the content'.

I have used this same XML/XSL in a VM development environment and it displays as expected, but when I try to create the same web part with the same XML/XSL in our test environment I get the said error. I have been working on this for some time and my google-fu isn't apparently working. Any idea what might be the issue or how to solve this? The only difference between the test and VM dev environments is that the test environment is two servers and load balanced. I have been told all other settings are the same.

Thanks in advance

*EDIT: So apparently I missed that there was a DOCTYPE defined for the XML in the test environment. Removing that allows it display. Since the XML will be coming from an outside source I will need to find out how to get around having a doctype defined.

1 Answer 1

1

The reason that this worked on a local VM and not in the test environment was because the service pack and CUs weren't installed on the VM. Once the VM was updated to the latest service pack and CU, the issue was replicated.

My solution, since I have no access to change the XML to remove the doctype, was to create custom web parts that did the call and display of data in code behind. It is no longer accessible for users to update, but these two specific web parts I was having trouble with were more a set it and forget type so no changes later should be necessary.

Hope it helps anyone who runs across this issue later.

2
  • Hey I am facing the exact same problem i.e. it is working fine on VM but not on test server. You say that we need to remove doctype from source XML to make it work but in my case there is no doctype defined in XML and still facing this issue. What could be the reason? Commented Jul 18, 2013 at 9:43
  • There are a quite a few different things that could be wrong to cause this error. It is pretty generic. Sometimes you can get a better understanding of what is failing by looking into the ULS log. Some of the common things I have found have been that the XSLT file was not well formed or the XML is not well formed. To troubleshoot I always strip it down to the bare minimum and start adding things back in. Commented Jul 18, 2013 at 21:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.