Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: Function in .Net not supported: unparsed-entity-uri

From: "Chris Lovett" <someone@------.------>
To: NULL
Date: 7/8/2005 1:23:00 AM
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
            version="1.0" xmlns:user="urn:user" 
exclude-result-prefixes="user">
  <xsl:output method="xml" indent="yes"/>
  <ms:script implements-prefix="user" 
xmlns:ms="urn:schemas-microsoft-com:xslt" language="C#" >
    <ms:using namespace="System.IO" />
    <ms:using namespace="System.Net" /><![CDATA[
    public string GetEntityAsBase64(XPathNodeIterator iter, string href) {
        iter.MoveNext();
        Uri baseUri = new Uri(iter.Current.BaseURI);
        Uri resolved = new Uri(baseUri, href);
        WebRequest req = WebRequest.Create(resolved);
        using (Stream stream = req.GetResponse().GetResponseStream()) {
            MemoryStream mem = new MemoryStream();
            int size = 10000;
            byte[] buffer = new byte[size];
            int len = 0;
            while ((len = stream.Read(buffer, 0, size)) > 0) {
                mem.Write(buffer, 0, len);
            }
            mem.Seek(0, SeekOrigin.Begin);
            return Convert.ToBase64String(mem.GetBuffer(), 
Base64FormattingOptions.InsertLineBreaks);
        }
    }]]>
    </ms:script>
  <xsl:output method="xml" encoding="UTF-8" />

  <xsl:template match="/attitude">
    <imagedata>
      <xsl:value-of select="user:GetEntityAsBase64(., 'image.jpg')"/>
    </imagedata>
  </xsl:template>
</xsl:stylesheet>

I created and debugged this using the Visual Studio 2005 XSL debugger :-)


"Harald Schmitt" <HaraldSchmitt@d...> wrote in message 
news:C1BF4145-DD48-4760-89DC-589222C44A91@m......
> This is not very nice. Because your nxslt tool is very good.
> Is there another way to get the content of an unparsed entity  with .net
> within an xslt script?
> I have an xml document with a dtd. I have the name of the unparsed entity 
> in
> an attributeand an the corresponding unparsed entity in the doctype
> decleration. I have to get the path of the (image) file (normally by
> unparsed-entity-uri) and encode it with base64 (I found your solution with
> C#) and embedd it in the output xml doc.
> Any suggestion?
>
> "Oleg Tkachenko [MVP]" wrote:
>
>> Harald Schmitt wrote:
>> > Thanks, I hope this will be fixed. For now I have to go back to msxsl 
>> > 4.0.
>>
>> Unfortunately not in .NET 2.0 :(
>>
>> -- 
>> Oleg Tkachenko [XML MVP, MCAD]
>> http://www.xmllab.net
>> http://blog.tkachenko.com
>> 




transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent