I got gray hairs because of this... I have created a xslt (the old xslt schema) for viewing data from a xml. The funny thing is that it works perfectly if I save the xml file on a server, but it dosen't when I set it to get the xml from the actual "source domain".
The error message I get:
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)
at umbraco.library.GetXmlDocumentByUrl(String Url, Int32 CacheInSeconds)
Am I blind or is it correct that I can't see the "renderFeed" template?
So you have created the feed yourself? Could this perhaps have something to do with the encoding of the XML document? Is it saved as UTF-8? (Long shot).
Forgot to tell... the code above is the is what calls the xml. I use this code on other websites to get weather data, but here it just won't work. I have tried with other urls in the code - and it works just great. But not with the feed I actually needs!
This one is giving a major headache...
UPDATE: The feed is created dynamicly on another website. It is thair productinformation I try to render on the website I'm currently working on. I have tried to make the feed both with and without the encoding... same result
The error you're receiving suggests to me that the feed has some erroneous Advertiser JavaScript/HTML in it, i.e., URLs containing unescaped & signs.
With a problem like this the 1st step you should take is to rule out ALL possibilities of a subtle error in your code causing this, and thus try something like this:
Create a new Macro using the "Clean" template and then do only this in the root template:
If that works, try the same without the textarea and see if what you got will parse as valid XML (copying from the textarea won't work, because the critical characters have been translated - copy from the raw source should work, though).
Copy the raw XML to a new document - save as feed.xml and open in Internet Explorer - it'll complain about anything that doesn't validate.
Thanks for all your replies! Sorry I let you wait so long...
We finally got it working! It turned out that the page with the feed couldn't handle the request becouse it was an .aspx page. After making it to a .ashx page it works perfect!
XSLT for external xml-feed - error when saving
Hi all,
I got gray hairs because of this... I have created a xslt (the old xslt schema) for viewing data from a xml. The funny thing is that it works perfectly if I save the xml file on a server, but it dosen't when I set it to get the xml from the actual "source domain".
The error message I get:
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)
at umbraco.library.GetXmlDocumentByUrl(String Url, Int32 CacheInSeconds)
The critical XSLT:
<xsl:variable name="feed" select="umbraco.library:GetXmlDocumentByUrl('http://xml.mysourcedomain.dk/info.aspx?ProductId=87181', number(1800))"/>
If I save the XML and put it on a server, like this:
<xsl:variable name="feed" select="umbraco.library:GetXmlDocumentByUrl('http://xml.mydomain.dk/87181.xml', number(1800))"/>
... it works perfect.
I hope some of you have a solution!! Thanks.
Note: The "critical xslt" acturlly contains "http://" in the url, but the forum mix it up...
Hi Kasper
What version of Umbraco is this happening on?
/Jan
umbraco v 4.0.3
Hi Kasper
What happens if you mit the cache parameter and only call the url?
Same error?
And are you sure that it's not another line in the XSLT the is the cause? Could you provide a bit more of the code?
/Jan
It's the same... I have research me to the conclusion that it is the feed and not the XSLT (as it is now) that causes the error...
A have cutted down the xml to only contain
Hi Kasper
Am I blind or is it correct that I can't see the "renderFeed" template?
So you have created the feed yourself? Could this perhaps have something to do with the encoding of the XML document? Is it saved as UTF-8? (Long shot).
/jan
Forgot to tell... the code above is the is what calls the xml. I use this code on other websites to get weather data, but here it just won't work. I have tried with other urls in the code - and it works just great. But not with the feed I actually needs!
This one is giving a major headache...
UPDATE: The feed is created dynamicly on another website. It is thair productinformation I try to render on the website I'm currently working on. I have tried to make the feed both with and without the encoding... same result
Yes, it's indeed an odd one. Probably one of those where it's just a little stupid thing that's the cause of all evil...
What does the renderFeed template look like?
/Jan
You asked for it...
Haha...I sure did...:-)
However...come to think about it...what does the first 4 lines look like? Do you have added some special entities in this part of the document?
<!DOCTYPE xsl:stylesheet [
<!ENTITY nbsp " ">
]>
/Jan
This is it
Hi Kasper,
The error you're receiving suggests to me that the feed has some erroneous Advertiser JavaScript/HTML in it, i.e., URLs containing unescaped & signs.
With a problem like this the 1st step you should take is to rule out ALL possibilities of a subtle error in your code causing this, and thus try something like this:
Create a new Macro using the "Clean" template and then do only this in the root template:
<xsl:template match="/"> <textarea cols="45" rows="30"><xsl:copy-of select="umbraco.library:GetXmlDocumentByUrl(URL_HERE, 0)" /></textarea> </xsl:template>
If that throws errors, you know it's in the feed and you can stop pulling hairs!
/Chriztian
If that works, try the same without the textarea and see if what you got will parse as valid XML (copying from the textarea won't work, because the critical characters have been translated - copy from the raw source should work, though).
Copy the raw XML to a new document - save as feed.xml and open in Internet Explorer - it'll complain about anything that doesn't validate.
/Chriztian
I got the same error.
So now, as you say, we are sure that the problem is the xml feed.
You guys write faster than I can reply... :-)
I copied the raw xml, and there where no complains anywhere.
In my mind the problem is moving towards the code that generates this feed.
Is that the complete feed?
If so, I guess you should try the feed URL in an HTTP application, like http://hurl.it or similar...
Maybe the feed URL redirects to another page? That could probably explain why the library function chokes on the result...?
/Chriztian
Hi
Thanks for all your replies! Sorry I let you wait so long...
We finally got it working! It turned out that the page with the feed couldn't handle the request becouse it was an .aspx page. After making it to a .ashx page it works perfect!
Thanks again - See you at CodeGarden11!
Hi Kasper
Great to hear you managed to solve this...what a weird one! But thanks for sharing the solution. It's always good to hear how it was solved.
But a bit strange the server could not handle the request when it was .aspx? Do you know why it could'nt?
/Jan
It seams because of the aspx file extension the request wasn’t sent to the xml site at all. It got blocked within the Umbraco site itself.
is working on a reply...