Copied to clipboard

Flag this post as spam?

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


  • Robert Valcourt 70 posts 103 karma points
    Feb 08, 2012 @ 07:46
    Robert Valcourt
    0

    umbraco.library:GetXmlDocumentByUrl fails and lags site if feed down

    I use umbraco.library:GetXmlDocumentByUrl to get XML data from an outside source. This source will, 99% of the time, send valid XML that umbraco's XSLT engine can parse. But every now and then the service goes does down and returns non Valid XML (it send standard HTML saying service is offline). When this happens, any page rendering the XSLT marco suffers long loading times while it times out.

    I'm trying to figure out how to tell umbraco to check for valid XML from the feed before trying to parse it. Here is a simple version of the current code:

    <xsl:variable name="feed" select="umbraco.library:GetXmlDocumentByUrl('http://domain.com/feed.xml',1)"/>
    <xsl:variable name="current" select="$feed//node()[name()='vwTOM_XML']"/>
    <p><xsl:value-of select="$current/node()[name()='NewSnow']"/></p>

    When the feed is down and is not sending valid XML, I need XSLT to detect this and fail quietly. For example:

    <xsl:variable name="feed" select="umbraco.library:GetXmlDocumentByUrl('http://domain.com/feed.xml',1)"/>
    <xsl:if test="$feed = valid XML">
      <xsl:variable name="current" select="$feed//node()[name()='vwTOM_XML']"/>
      <p><xsl:value-of select="$current/node()[name()='NewSnow']"/></p>
    </xsl:if>

    Is what i'm trying to do in any way possible? Ultimately the cause of the failure is when XSLT tries to read the value of $feed//node()[name()='vwTOM_XML'] when it doesn't exist.

     

Please Sign in or register to post replies

Write your reply to:

Draft