Altova Mailing List Archives>Archive Index >microsoft.public.xsl Archive Home >Recent entries >Thread Prev - Re: Function in .Net not supported: unparsed-entity-uri >Thread Next - Re: Function in .Net not supported: unparsed-entity-uri Re: Function in .Net not supported: unparsed-entity-uriTo: 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
>>
| ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
