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

Ondrej Pokorny lazarus at kluug.net
Fri Dec 30 19:13:32 CET 2022


On 30.12.2022 16:59, Michael Van Canneyt via Pas2js wrote:
> 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 ?

I think you are right that this is not a task for Pas2JS.

I will do it as a Lazarus package. This gives me more possibilities 
(well, I don't know yet how to do it but it is always possible to extend 
the IDEIntf API).

I will definitely write back about my success.

Thanks
Ondrej



More information about the Pas2js mailing list