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-uriTo: NULL Date: 7/11/2005 6:09:00 PM Harald Schmitt wrote: > 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. In .NET you can use extention function to resolve unparsed entities. Something like this: <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns:user="urn:user" exclude-result-prefixes="user"> <ms:script implements-prefix="user" xmlns:ms="urn:schemas-microsoft-com:xslt" language="C#"> public string getEntityURI(XPathNodeIterator node, string entityName) { if (node.MoveNext()) { XmlDocument document = ((IHasXmlNode)node.Current).GetNode().OwnerDocument; XmlEntity entity = (XmlEntity)document.DocumentType.Entities.GetNamedItem(entityName); return entity.SystemId; } return ""; } </ms:script> <xsl:template match="graphic"> <xsl:value-of select="user:getEntityURI(., @ent)"/> </xsl:template> </xsl:stylesheet> And make sure your source XML is loaded to XmlDocument, because XPathDocument doesn't preserve DOCTYPE. -- 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 | |||
|
