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 4:09:00 PM Thanks, but it did not solve my problem! I have a file like: <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE standard [ <!NOTATION GIF SYSTEM "GIF"> <!NOTATION EPS SYSTEM "EPS"> <!ENTITY SLE47659 SYSTEM "47659.eps" NDATA EPS> <!ENTITY SLE42925 SYSTEM "42925.gif" NDATA GIF> ]> <standard> <graphic ent="SLE47659"/> <graphic ent="SLE42925"/> </standard> and I want in the output file the content of the files in base64 encoded. First step is to resolve SLE47659 to 47659.eps. 2. Step read the file and encode it as base64. All within XSLT. Step 2 is covered by you and I found a algorithm from Oleg, too. But that does not help without step 1! Do you have a base64 encoding in VBScript? Then I could embed it in MSXSL 4.0. There I can do the 1. step. Thanks Harald "Chris Lovett" wrote: > <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[] 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 | |||
|
