Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


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

From: "Oleg Tkachenko [MVP]" <oleg@--!----!---------------.--->
To: 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


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