Copied to clipboard

Flag this post as spam?

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


  • Mikkel B. Mikkelsen 52 posts 81 karma points
    Aug 20, 2012 @ 15:49
    Mikkel B. Mikkelsen
    0

    Textstring array datatype throws xml exception

    I have a textstring array with 3 columns, width, height and format as pictured below

    When I try i to get the values through razor using:

    @Model.NodeById(imageBankNodeId).dimensions

    I get the following error:

    Error Loading Razor Script (file: Image Bank Search) Data at the root level is invalid. Line 1, position 1.    at System.Xml.XmlTextReaderImpl.Throw(Exception e)
    at System.Xml.XmlTextReaderImpl.Throw(String res, String arg)
    at System.Xml.XmlTextReaderImpl.ParseRootLevelWhitespace()
    at System.Xml.XmlTextReaderImpl.ParseDocumentContent()
    at System.Xml.XmlTextReaderImpl.Read()
    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 uComponents.Core.DataTypes.TextstringArray.TextstringArrayModelBinder.Init(Int32 CurrentNodeId, String PropertyData, Object& instance)
    at umbraco.MacroEngines.DynamicNode.TryCreateInstanceRazorDataTypeModel(Guid dataType, Type dataTypeType, String value, Object& result)
    at umbraco.MacroEngines.DynamicNode.TryGetMember(GetMemberBinder binder, Object& result)
    at CallSite.Target(Closure , CallSite , Object )
    at System.Dynamic.UpdateDelegates.UpdateAndExecute1[T0,TRet](CallSite site, T0 arg0)
    at ASP._Page_macroScripts_imageBankSearch_cshtml.Execute() in c:\inetpub\wwwroot\Logitrans\macroScripts\imageBankSearch.cshtml:line 175
    at System.Web.WebPages.WebPageBase.ExecutePageHierarchy()
    at System.Web.WebPages.WebPage.ExecutePageHierarchy(IEnumerable`1 executors)
    at System.Web.WebPages.WebPage.ExecutePageHierarchy()
    at System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage)
    at umbraco.MacroEngines.RazorMacroEngine.ExecuteRazor(MacroModel macro, INode currentPage)
    at umbraco.MacroEngines.RazorMacroEngine.Execute(MacroModel macro, INode currentPage)

    If I try getting the value ike this:

    @Model.NodeById(imageBankNodeId).GetProperty("dimensions")

    the output is all the data concatenated together like so

    19201600jpg16001280tif

    I'm running uComponents v4.0, any suggestions?

  • Tom Fulton 2030 posts 4998 karma points c-trib
    Aug 20, 2012 @ 16:48
    Tom Fulton
    0

    Hi Mikkel,

    Can you try finding the property in umbraco.config and paste the full XML here?  Sounds like it might be formatted incorrectly for some reason

    -Tom

  • Mikkel B. Mikkelsen 52 posts 81 karma points
    Aug 21, 2012 @ 08:13
    Mikkel B. Mikkelsen
    0

    Hm, I can't actually seem to find it in the xml. The property is attached to a media node, whose ID doesn't seem to appear in the umbraco.config file.

    EDIT:

    I managed to dig out the values from the database. I've tried recreating the umbraco.config file a number of times but the values still don't appear in the xml, and neither does the media node id.

    This is whats in the database:

    [["1920","1600","jpg"],["1600","1280","tif"]]
  • Tom Fulton 2030 posts 4998 karma points c-trib
    Aug 21, 2012 @ 20:24
    Tom Fulton
    0

    Hi Mikkel,

    Ah, I didn't realize you were doing this in Media and not Content.  This actually makes sense because I've seen a similar issue, it seems that Razor doesn't load XML properly for media properties.  I tried to find a quick workaround but nothing came up, I might see if I can look into this more later as I'm curious.  

    As a temporary workaround you might use XSLT or try disabling uComponents Razor ModelBinding (though not sure if this will fix the issue completely, the data still may not be in a usable form).

    - Tom

  • Mikkel B. Mikkelsen 52 posts 81 karma points
    Aug 21, 2012 @ 20:30
    Mikkel B. Mikkelsen
    0

    Hey Tom, thanks for looking into it. I ended up using a pretty crude workaround, but it'll do for now.

    Entered a delimiter into the data so i could split the string and have it sort of work till i find a better solution.

Please Sign in or register to post replies

Write your reply to:

Draft