Project

Profile

Help

Support #6399

open

Is XmlProcessingError.IsWarning supposed to be "false" for SXWNxxxx?

Added by Emanuel Wlaschitz 7 months ago. Updated 7 months ago.

Status:
In Progress
Priority:
Low
Assignee:
-
Category:
.NET API
Sprint/Milestone:
-
Start date:
2024-04-16
Due date:
% Done:

0%

Estimated time:
Legacy ID:
Applies to branch:
10
Fix Committed on Branch:
Fixed in Maintenance Release:
Platforms:
.NET

Description

I know that Saxon 10 is pretty much on life-support at this point and unlikely to see another release beyond 10.9 (hence why I tagged this as "Support" rather than "Bug") but I just stumbled over one of the last tools that was still on Saxon 9.9: A tiny console application that runs in our CI to ensure we don't forget about other affected XSLT when re-using/changing modules.

I basically spin up a XSLT Compiler, compile a list of defined root XSLTs (files that include others thru xsl:import/xsl:include) and capture any exceptions/errors that come out:

var processor = new Processor();
var compiler = processor.NewXsltCompiler();
var staticErrors = new List<XmlProcessingError>();
compiler.SetErrorList(staticErrors);

// try/catch/etc. omitted for brevity
_ = compiler.Compile(GetStyleURI("validate.xsl"));

foreach (var staticError in staticErrors)
{
    var console = staticError.IsWarning ? Console.Out : Console.Error;
    console.WriteLine("[{0}] {1} ({2})",
        staticError.IsWarning ? "WARN" : "ERROR",
        GetMessage(staticError),
        GetLocation(staticError));
}

With 10.9 (from NuGet) every single staticError has IsWarning set to false, even the ones that used to be warnings with 9.9 (basically anything in the SXWNxxxx range.) At a glance, this feels like an oversight; or a gap in documentation elsewhere (at least I couldn't find anything for this.)

I see that AsWarning (not IsWarning) exists as well, but that one just gives me a copy that has IsWarning blindly set to true.

Is there any way to figure out if something is a warning (something that should be addressed while the XSLT still works) and not a hard error (something that normally causes the XSLT to fail completely) without basically testing for staticError.ErrorCode.LocalName.StartsWith("SXWN") in my code? I can imagine there are other codes that aren't technically errors (that would fail this test); and not every StaticError has an ErrorCode (one that we tend to run into is "Stylesheet module included.xsl is included or imported more than once. This is permitted, but may lead to errors or unexpected behavior")

Again, mostly looking for ideas on how to get this little tool onto 10.9 so it matches the rest of our landscape (and may support those that run on it) without causing too much of a ruckus. I don't really expect to see a 10.10 maintenance release to address this (although, it would be 10/10 if there was one :) )


Files

clipboard-202404250755-c072v.png (61 KB) clipboard-202404250755-c072v.png Screenshot from the Visual Studio Debugger Emanuel Wlaschitz, 2024-04-25 07:55

Please register to edit this issue

Also available in: Atom PDF