Path: redb-route/redb.Route/Xslt/XsltSupport.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/Xslt/XsltSupport.cs
----
using redb.Route.Abstractions;
namespace redb.Route.Xslt;
/// Well-known message headers for the XSLT transform (Apache Camel names).
public static class XsltHeaders
{
/// Header carrying a stylesheet file path / URI to use for this message
/// (honoured only when allowTemplateFromHeader is enabled).
public const string ResourceUri = "CamelXsltResourceUri";
/// Header carrying an inline stylesheet document to use for this message
/// (honoured only when allowTemplateFromHeader is enabled).
public const string Stylesheet = "CamelXsltStylesheet";
}
///
/// Collects XSLT stylesheet parameters from the exchange. Mirrors Apache Camel, which makes all
/// message headers (and exchange variables/properties) available as xsl:param — a stylesheet
/// only sees the ones it declares. Values are passed as strings; the transform silently ignores keys
/// that are not usable parameter names.
///
public static class XsltParameters
{
/// Builds the parameter map (headers first, then properties without overwriting).
public static IReadOnlyDictionary FromExchange(IExchange exchange)
{
var parameters = new Dictionary(StringComparer.Ordinal);
foreach (var (key, value) in exchange.In.Headers)
if (value is not null)
parameters[key] = value.ToString();
foreach (var (key, value) in exchange.Properties)
if (value is not null && !parameters.ContainsKey(key))
parameters[key] = value.ToString();
return parameters;
}
}