Skip to content

Instantly share code, notes, and snippets.

@stakx
Last active October 24, 2016 21:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stakx/fbbd5e7319bd6c281c50b4ebb1cee1f9 to your computer and use it in GitHub Desktop.
Save stakx/fbbd5e7319bd6c281c50b4ebb1cee1f9 to your computer and use it in GitHub Desktop.
XmlResolverSandbox
<?xml version="1.0"?>
<configuration>
<configSections>
</configSections>
<connectionStrings>
<add name="SqlServerDatabase" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\SqlServerDatabase.mdf;Integrated Security=True;User Instance=True" providerName="System.Data.SqlClient"/>
</connectionStrings>
<startup><supportedRuntime version="v2.0.50727"/></startup></configuration>
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// Allgemeine Informationen über eine Assembly werden über die folgenden
// Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern,
// die mit einer Assembly verknüpft sind.
[assembly: AssemblyTitle("XmlResolverSandbox")]
[assembly: AssemblyDescription("As described at http://stackoverflow.com/a/12007105/240733.")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("")]
[assembly: AssemblyCopyright("stakx")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Durch Festlegen von ComVisible auf "false" werden die Typen in dieser Assembly unsichtbar
// für COM-Komponenten. Wenn Sie auf einen Typ in dieser Assembly von
// COM zugreifen müssen, legen Sie das ComVisible-Attribut für diesen Typ auf "true" fest.
[assembly: ComVisible(false)]
// Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird
[assembly: Guid("81f58319-8d96-4879-9362-9c9f6c0053f1")]
// Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten:
//
// Hauptversion
// Nebenversion
// Buildnummer
// Revision
//
// Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern
// übernehmen, indem Sie "*" eingeben:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="Foo">
<Bar/>
</xsl:template>
</xsl:stylesheet>
using System;
using System.Xml;
public interface IDatabaseService
{
XmlReader GetApplicationXslt(String applicationName);
XmlReader GetAreaXslt(String applicationName, String areaName);
XmlReader GetSubareaXslt(String applicationName, String areaName, String subAreaName);
XmlReader GetSubareaXmlPreTransformXslt(String applicationName, String areaName, String subAreaName);
}
using System;
using System.Xml;
using System.Xml.Xsl;
using System.Text;
class Program
{
static void Main(string[] args)
{
var databaseService = new SqlServerDatabaseService();
databaseService.StoreApplicationDocument("common", XmlReader.Create("CommonHistOrg.xslt"));
databaseService.StoreApplicationDocument("test", XmlReader.Create("TestStylesheet.xslt"));
var input = XmlReader.Create("TestInput.xml");
var xslt = new XslCompiledTransform();
xslt.Load("db://test.hist.org",
settings: XsltSettings.Default,
stylesheetResolver: new XmlDbResolver(databaseService));
var output = new StringBuilder();
xslt.Transform(input, XmlWriter.Create(output));
Console.WriteLine(output.ToString());
Console.ReadLine();
}
}
This file has been truncated, but you can view the full file.
View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment