private XslCompiledTransform Load(bool computeSize) { try { string xslLocation = "oox2Daisy.xsl"; XPathDocument xslDoc = null; XmlUrlResolver resolver = this.ResourceResolver; if (this.ExternalResources == null) { if (computeSize) { xslLocation = "oox2Daisy.xsl"; } EmbeddedResourceResolver emr = (EmbeddedResourceResolver)resolver; emr.IsDirectTransform = this.DirectTransform; xslDoc = new XPathDocument(emr.GetInnerStream(xslLocation)); } else { xslDoc = new XPathDocument(this.ExternalResources + "/" + xslLocation); } if (!this.compiledProcessors.Contains(xslLocation)) { #if DEBUG XslCompiledTransform xslt = new XslCompiledTransform(true); #else XslCompiledTransform xslt = new XslCompiledTransform(); #endif // compile the stylesheet. // Input stylesheet, xslt settings and uri resolver are retrieve from the implementation class. xslt.Load(xslDoc, this.XsltProcSettings, this.ResourceResolver); this.compiledProcessors.Add(xslLocation, xslt); } return((XslCompiledTransform)this.compiledProcessors[xslLocation]); } catch (Exception e) { string s; s = e.Message; return(null); } }
/* Function to get Stream of a file using its URI*/ public override object GetEntity(Uri absoluteUri, string role, Type ofObjectToReturn) { try { Stream stream = null; if (entries.Contains(absoluteUri.AbsoluteUri)) { PackagePart archivepart; string aparturi; aparturi = "/" + (string)entries[absoluteUri.AbsoluteUri]; Uri archiveparturi = new Uri(aparturi, UriKind.Relative); archivepart = archive.GetPart(archiveparturi); stream = archivepart.GetStream(); } if (stream == null) { stream = new MemoryStream(); } // Cannot have a 0 byte xml document ! else if (stream.Length == 0) { throw new IOException(entries[absoluteUri.AbsoluteUri] + " is 0 length"); } return(stream); } catch (Exception e) { // failsafe on a dummy xml document string s; s = e.Message; return(EmbeddedResourceResolver.GetSharedResource("source.xml")); } }