Path: redb-route/redb.Route/Definitions/XsltDefinition.cs Snapshot: redb-route, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages. License: Apache-2.0. Repository: https://github.com/redbase-app/redb-route Page: https://redbase.app/src/dev-2026-12-06/redb-route/redb.Route/Definitions/XsltDefinition.cs ---- using redb.Route.Abstractions; using redb.Route.Core; using redb.Route.Xslt; namespace redb.Route.Definitions; /// /// Leaf definition that transforms the exchange body through an XSLT stylesheet loaded from a /// file (Apache Camel xslt: parity). The stylesheet is compiled once when the route is /// built and reused for every message. xsl:import/xsl:include resolve relative to the file. /// public sealed class XsltFileDefinition : ProcessorDefinition { private readonly string _stylesheetPath; private readonly XsltOutput _output; private readonly bool _failOnNullBody; private readonly bool _allowTemplateFromHeader; /// Creates a file-based XSLT definition. public XsltFileDefinition( string stylesheetPath, XsltOutput output = XsltOutput.String, bool failOnNullBody = true, bool allowTemplateFromHeader = false) { ArgumentException.ThrowIfNullOrWhiteSpace(stylesheetPath); _stylesheetPath = stylesheetPath; _output = output; _failOnNullBody = failOnNullBody; _allowTemplateFromHeader = allowTemplateFromHeader; } /// public override IProcessor CreateProcessor(IRouteContext context) { var engines = context.GetXsltEngineFactory(); // Through the context's resource resolver, as the xslt: endpoint and validateXsd do: a stylesheet inside a package // is found where the package keeps its resources, not under the worker's working directory. string Resolve(string path) => ResourceResolution.Resolve(context, path, "XSLT stylesheet"); return new XsltProcessor( engines.FromFile(Resolve(_stylesheetPath)), _output, _failOnNullBody, allowTemplateFromHeader: _allowTemplateFromHeader, fileEngineFactory: path => engines.FromFile(Resolve(path)), contentEngineFactory: engines.FromContent); } } /// /// Leaf definition that transforms the exchange body through an inline XSLT stylesheet document /// (self-contained; no xsl:import/xsl:include base URI). Compiled once at route build. /// public sealed class XsltContentDefinition : ProcessorDefinition { private readonly string _stylesheetXml; private readonly XsltOutput _output; private readonly bool _failOnNullBody; private readonly bool _allowTemplateFromHeader; /// Creates an inline-stylesheet XSLT definition. public XsltContentDefinition( string stylesheetXml, XsltOutput output = XsltOutput.String, bool failOnNullBody = true, bool allowTemplateFromHeader = false) { ArgumentException.ThrowIfNullOrWhiteSpace(stylesheetXml); _stylesheetXml = stylesheetXml; _output = output; _failOnNullBody = failOnNullBody; _allowTemplateFromHeader = allowTemplateFromHeader; } /// public override IProcessor CreateProcessor(IRouteContext context) { var engines = context.GetXsltEngineFactory(); return new XsltProcessor( engines.FromContent(_stylesheetXml), _output, _failOnNullBody, allowTemplateFromHeader: _allowTemplateFromHeader, fileEngineFactory: engines.FromFile, contentEngineFactory: engines.FromContent); } }