Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Lachlann 344 posts 626 karma points
    Oct 18, 2009 @ 13:12
    Lachlann
    0

    XSLT error while parsing EntityName

    Hi there,

    i have an install of umbraco v 4.0.2.1 (Assembly version: 1.0.3441.17657)

    Last night my site was working fine, but today when i was checking over it i get an xslt error. When i went to the developer section in the back end and tried to save the file i get the following error

    System.Xml.XmlException: An error occurred while parsing EntityName. Line 4, position 106.
    at System.Xml.XmlTextReaderImpl.Throw(Exception e)
    at System.Xml.XmlTextReaderImpl.Throw(String res, String arg)
    at System.Xml.XmlTextReaderImpl.Throw(String res)
    at System.Xml.XmlTextReaderImpl.ParseEntityName()
    at System.Xml.XmlTextReaderImpl.ParseEntityReference()
    at System.Xml.XmlTextReaderImpl.Read()
    at System.Xml.XmlLoader.LoadNode(Boolean skipOverWhitespace)
    at System.Xml.XmlLoader.LoadDocSequence(XmlDocument parentDoc)
    at System.Xml.XmlLoader.Load(XmlDocument doc, XmlReader reader, Boolean preserveWhitespace)
    at System.Xml.XmlDocument.Load(XmlReader reader)
    at System.Xml.XmlDocument.LoadXml(String xml)
    at umbraco.library.GetXmlDocumentByUrl(String Url)

     

    Im pretty sure i haven't changed anything here. Can anyone tell me what this error means? i think the lines of code it is refereing to are:

     

    <xsl:stylesheet
        version="1.0"
        xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
        xmlns:msxml="urn:schemas-microsoft-com:xslt"
        xmlns:umbraco.library="urn:umbraco.library"
        xmlns:Exslt.ExsltCommon="urn:Exslt.ExsltCommon"
        xmlns:Exslt.ExsltDatesAndTimes="urn:Exslt.ExsltDatesAndTimes"
        xmlns:Exslt.ExsltMath="urn:Exslt.ExsltMath"
        xmlns:Exslt.ExsltRegularExpressions="urn:Exslt.ExsltRegularExpressions"
        xmlns:Exslt.ExsltStrings="urn:Exslt.ExsltStrings"
        xmlns:Exslt.ExsltSets="urn:Exslt.ExsltSets"
        xmlns:CWS.Twitter="urn:CWS.Twitter"
        exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets CWS.Twitter">

     

    I want to try and launch this site today so this is a really pressing issue any help would be really really appreciated.

     

    Lach

  • Lachlann 344 posts 626 karma points
    Oct 18, 2009 @ 13:18
    Lachlann
    0

    Okay this xslt file uses warren buckley's twitter-for-umbraco if i remove the element that calls this from the page the xslt will parse correctly in the front end. Does anyone have any idea why this might switch overnight? maybe somehting to do with twitter?

     

     

  • Sebastiaan Janssen 5045 posts 15476 karma points MVP admin hq
    Oct 18, 2009 @ 13:20
    Sebastiaan Janssen
    0

    Hey Lach, the code that you're posting is actually seen as one line, so that line is not the source of the problem. However, you might have installed packages that change this line, I see CWS.Twitter for example, maybe that's new?

    It could be that you're trying to pass some new content through this XSLT that has illegal characters in it, has your content changed lately?

    What I tend to do in these situations is comment out all of my XSLT and selectively enable bits to see where the error might be. I can usually find the problem within a few minutes of trial and error like that.

  • Sebastiaan Janssen 5045 posts 15476 karma points MVP admin hq
    Oct 18, 2009 @ 13:21
    Sebastiaan Janssen
    0

    Ah, too late. It might be one of your tweets causing the problem? Try switching on output escaping for the Twitter content.

  • Lachlann 344 posts 626 karma points
    Oct 18, 2009 @ 13:24
    Lachlann
    0

    Hey Sebastiaan,

    Thanks i will give this a go, the code in question seems to be the CWS.Twitter but this has been working fine for months. I think the issue must be with the twitter details perhaps, or maybe some new twitter content that is coming through.

     

    Thanks

  • Morten Bock 1867 posts 2140 karma points MVP 2x admin c-trib
    Oct 18, 2009 @ 13:38
    Morten Bock
    0

    I have just seen this exception. It is typiacally because some xml looks like this:

    <test>text & text</test>

    This is not valid xml, because the & needs to be html encoded:

    <test>text &amp; text</test>

    If it is the twitter feed or the handling of it that is invalid, I don't know.

  • Sebastiaan Janssen 5045 posts 15476 karma points MVP admin hq
    Oct 18, 2009 @ 13:43
    Sebastiaan Janssen
    0

    Yep Morten, that is where I seem to recall getting this error as well. I am hoping that disable-output-escaping="no" would do the trick, but I'm not sure in this case...

  • Lachlann 344 posts 626 karma points
    Oct 18, 2009 @ 14:01
    Lachlann
    0

    I think i have found the line which is causing the problem and form looking at the twitter stream there are some & in there.

    the line is:

     <xsl:apply-templates mode="tweet" select="umbraco.library:GetXmlDocumentByUrl($twitterXMLUrl)//statuses/status" />

     

    i have tried

     <xsl:apply-templates mode="tweet" select="umbraco.library:HtmlEncode(umbraco.library:GetXmlDocumentByUrl($twitterXMLUrl)//statuses/status)" />

     

    but that seems to have no effect.

     

    ahhhh.

  • Sebastiaan Janssen 5045 posts 15476 karma points MVP admin hq
    Oct 18, 2009 @ 14:07
    Sebastiaan Janssen
    0

    Try changing this line:

    <xsl:value-of select="CWS.Twitter:FormatURLS(text)" disable-output-escaping="yes"/>

    See what happens if the output escaping is not disabled:

    <xsl:value-of select="CWS.Twitter:FormatURLS(text)" disable-output-escaping="no"/>
  • Lachlann 344 posts 626 karma points
    Oct 18, 2009 @ 14:10
    Lachlann
    0

    Hey Sebastiaan

    I tried this but i think the parsing error is being thrown when i call the template,

    <xsl:apply-templates mode="tweet" select="umbraco.library:GetXmlDocumentByUrl($twitterXMLUrl)//statuses/status" /> 

    Even if i remove theline

    <xsl:value-of select="CWS.Twitter:FormatURLS(text)" disable-output-escaping="yes"/>

    i still get the parsing error until i remove the call to the template.

     

    L

  • Sebastiaan Janssen 5045 posts 15476 karma points MVP admin hq
    Oct 18, 2009 @ 14:15
    Sebastiaan Janssen
    0

    Okay, this might help:

    <xsl:apply-templates mode="tweet" select="umbraco.library:Replace(umbraco.library:GetXmlDocumentByUrl($twitterXMLUrl)//statuses/status)", '&', '&amp;') />

     

     

  • Lachlann 344 posts 626 karma points
    Oct 18, 2009 @ 14:27
    Lachlann
    0

    Hey Sebastiaan

    now i get this:

    System.Xml.XmlException: An error occurred while parsing EntityName. Line 53, position 135.

    which is the line i inserted the string replace on!

    L

     

  • Lachlann 344 posts 626 karma points
    Oct 18, 2009 @ 14:48
    Lachlann
    0

    I have tried witching the twitter stream that this is using and i am still getting the same error. I wonder if something could have chnaged with the way twitter is outputing it's feed xml? is ayone else usng the twitter package? are you having this problem?

    L

  • Sebastiaan Janssen 5045 posts 15476 karma points MVP admin hq
    Oct 18, 2009 @ 18:33
    Sebastiaan Janssen
    0

    What a shame that this problem is so persistent, I've installed the package and it works perfectly over here. I even sent myself a tweet with a "&" in it and it still works great.

    Maybe you should try re-installing the package? Could be that the XSLT file got corrupted somehow? I don't know what else to tell you.

  • Morten Bock 1867 posts 2140 karma points MVP 2x admin c-trib
    Oct 19, 2009 @ 22:04
    Morten Bock
    2

    The problem is not in the XSLT. It is the internals of the GetXmlDocumentByUrl.

    Internally, that tries to parse the xml feed into and XmlDocument, and that is the part that throws the error. So there is nothing you can do inside the XSLT that will fix it. You would need to write your own C# method to get and parse the feed, before making it an XmlDocument.

    Could you give us the link to the feed to find the problem? Maybe it is easy to fix in the original feed...

  • Neil Tootell 73 posts 118 karma points
    Apr 29, 2010 @ 18:35
    Neil Tootell
    0

    Hi all,

    Sorry for the late reply on this but we've just had exactly the same problem. For us it turned out to be a heavy handed firewall rule that was blocking DNS queries. 

    It meant the GetXmlDocumentByUrl function couldn't see the outside world. Worth checking with your host if you've exhausted other avenues.

     

    n

  • Lee 1130 posts 3088 karma points
    May 05, 2010 @ 10:42
    Lee
    0

    I have just got this problem, its definitely something to do with the twitter XML as its happened on two sites both using different twitter projects

Please Sign in or register to post replies

Write your reply to:

Draft