Copied to clipboard

Flag this post as spam?

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


  • kashif 18 posts 38 karma points
    Nov 09, 2010 @ 12:24
    kashif
    0

    Reading Compressed Binary XML with Extension

    Hi, all,

    I have a library in .net which first compressed the xml data ( via Gzip) in memory then generate the xml files in binary via Binary Writer. It also have another method to read these compressed binary files, which is working fine outside Umbraco.

    I have created an XSLT extension for this library in umbraco and try to used it. But unfortunately whenever i tried to read the binary compressed file then i am not able to save it in XSLT editor and receiving this error.

    Error occured

    System.ArgumentException: '.', hexadecimal value 0x00, is an invalid character. 
    at System.Xml.XmlEncodedRawTextWriter.InvalidXmlChar(Int32 ch, Char* pDst, Boolean entitize) 
    at System.Xml.XmlEncodedRawTextWriter.WriteElementTextBlock(Char* pSrc, Char* pSrcEnd) 
    at System.Xml.HtmlEncodedRawTextWriter.WriteString(String text) 
    at (XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}runtime, XPathNavigator {urn:schemas-microsoft-com:xslt-debug}current) 
    at Root(XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}runtime) 
    at Execute(XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}runtime) 
    at System.Xml.Xsl.XmlILCommand.Execute(Object defaultDocument, XmlResolver dataSources, XsltArgumentList argumentList, XmlSequenceWriter results) 
    at System.Xml.Xsl.XmlILCommand.Execute(Object defaultDocument, XmlResolver dataSources, XsltArgumentList argumentList, XmlWriter writer) 
    at System.Xml.Xsl.XslCompiledTransform.Transform(IXPathNavigable input, XsltArgumentList arguments, XmlWriter results, XmlResolver documentResolver) 
    at System.Xml.Xsl.XslCompiledTransform.Transform(IXPathNavigable input, XsltArgumentList arguments, TextWriter results) 
    at umbraco.presentation.webservices.codeEditorSave.SaveXslt(String fileName, String oldName, String fileContents, Boolean ignoreDebugging)

    I have tried to Skip testing (ignore errors) then it said Error parsing XSLT file: \xslt\View.xslt

    Same code is working fine outside the Umbraco but not working in Umbraco. Previously i have tested "hello world" function via extension is working fine. So it means no issue in configuration of extension. Please also provide me hints how to debug it in umbraco.


     

  • kashif 18 posts 38 karma points
    Nov 09, 2010 @ 12:31
    kashif
    0

    Code which i am using in XSLT Editor,

    <xsl:value-of select="XMLMgr:BinaryFileReader('C:\myfile.xml')" />

    reading a text XML file have no issue but whenever i tried to read binary file via above method then it doesn't work.

    Seems some nulls are generating but not sure where ?

  • kashif 18 posts 38 karma points
    Nov 13, 2010 @ 14:58
    kashif
    0

    It was special characters issues which i removed by a function. Now i have my xml placed in seperate files which i am calling in Umbraco is in form of this:

    <?xml version="1.0" encoding="utf-8"?>

    <DM TotalNodes="111">

    <product>

    <name> product 1 </name>

    <price>12</price>

    </product>

    <product>

    <name> product 2 </name>

    <price>15</price>

    </product>

    .

    .

    .

    </DM>


    In order to render the xml i have createed an xslt file with this code in it, but i am not able to see anything and there is no error.:

     <xsl:template match="/">

     <xsl:variable name="XMLData" select="Utility:RemoveTroublesomeCharacters(XMLMgr:BinaryFileReader($url))" />

     <xsl:call-template name="p1">
           <xsl:with-param name="data" select="$XMLData" />
       </xsl:call-template>

       </xsl:template>

       <xsl:template name="p1">
       <xsl:param name="data"  />

      <xsl:for-each select="msxsl:node-set($data)//product">

              Name:  <xsl:value-of select="name" disable-output-escaping="yes"/>

       </xsl:for-each>

       </xsl:template>

     

Please Sign in or register to post replies

Write your reply to:

Draft