[Pas2js] Pas2JS: compiler extension to validate XML/XSLT files

Michael Van Canneyt michael at freepascal.org
Fri Dec 30 16:59:38 CET 2022



On Fri, 30 Dec 2022, Michael Van Canneyt via Pas2js wrote:

>> Where should I start? I see 2 possible routes:
>> 
>> 1.) Pas2JS compiler extension: hook into handling {$R *.xslt} and abort 
>> compilation with an error in case of invalid xslt file.
>
> No, this is not acceptable.
>
>> 2.) Lazarus extension: create a package that hooks into the Compile command 
>> and checks all XSLT/XML files in the project before the project is compiled 
>> with Pas2JS.
>> 
>> I would prefer (1) because it the XSLT don't have to be registered in the 
>> LPI project.
>
> No. pas2js must compile pascal code, end of story.

After reading my own reply, I didn't like the tone of what I wrote.

Sorry about that.

Little more background: 
as I wrote, pas2js must compile code, no more, no less.

I've had proposals of generating/interpreting html, CSS:
All proposals for which I understand why people ask that, 
but then there will be no limit.

So, the best course of action is to limit
pas2js to what it must do: compile code.

There is a preprocessor option, you can tell pas2js to preprocess the input
file.

Expanding on that, concept is maybe a solution that could help you:

What we could envision is a preprocessor for the {$R} which can be specified
on the command line, per extension. Something like:
-FPxslt=path/to/your/tool.

This handler would receive 2 names:
- InputFileName
- OutputFileName
when it sees the {$R}, the compiler generates an output filename and calls
the tool with the 2 filenames. When the tool is done, the compiler includes 
the generated file. 
(you can just copy the file if you don't need additional processing)

What do you think about that approach ?

Michael.



More information about the Pas2js mailing list