PhoenixmlDb.XSLT
PreloadedResources
Pre-fetched contents for URIs that the engine would otherwise need to fetch over the network synchronously (xsl:import, xsl:include, fn:doc()).
#PreloadedResources
Namespace: PhoenixmlDb.Xslt
Pre-fetched contents for URIs that the engine would otherwise need to fetch over the network synchronously (
xsl:import
,
xsl:include
,
fn:doc()
).
On runtimes that support thread blocking (server, desktop, CLI), the engine's HTTP loaders run an async HttpClient call to completion synchronously. That's fine for those runtimes — but Blazor WebAssembly is single-threaded and cannot park a thread on a monitor wait, so the same code throws "Cannot wait on monitors on this runtime".
To run on WASM, fetch the resources asynchronously in your host code (via HttpClient with await, or via JS interop) and pass the contents through a PreloadedResources instance to XsltTransformer.LoadStylesheetAsync. The engine consults this cache before falling back to its synchronous HTTP loaders.
On WASM, a cache miss for an absolute http(s) URI raises a clear engine exception that names the missing URI rather than the obscure runtime Cannot wait on monitors error.
#Example
// Blazor WebAssembly: pre-fetch every URI the stylesheet will need before loading.
var http = new HttpClient();
var transpileXsl = await http.GetStringAsync("https://example.org/transpile.xsl");
var priceSch = await http.GetStringAsync("https://example.org/price.sch");
var preloaded = new PreloadedResources();
preloaded.Add(new Uri("https://example.org/transpile.xsl"), transpileXsl);
preloaded.Add(new Uri("https://example.org/price.sch"), priceSch);
var t = new XsltTransformer();
await t.LoadStylesheetAsync(stylesheetXml, baseUri, preloadedResources: preloaded);
var result = await t.TransformAsync(sourceXml);
#Properties
| Name | Description |
|---|---|
Count
|
Number of URIs registered. |
#Methods
#Add(Uri,String)
Adds
for
. Existing entries are overwritten.
#Clear
Clears all entries.
#Contains(Uri)
True if a pre-loaded entry exists for
.
#CreateBrowserCacheMissException(Uri,String)
Helper used by the engine's HTTP loader fallbacks to surface a clear, actionable error when running on a runtime that cannot block the calling thread (Blazor WebAssembly).
#TryGet(Uri,String@)
Tries to retrieve the pre-loaded content for
.