Hello!
A short background:
I've learned how to use Pas2JS to write web client applications. I developed for it a simple but very powerful method: 1.) The server sends JSON objects as responses.
2.) The client converts these JSON objects to XML and uses XSLT templates to generate XHTML for the browser.
XSLT is for Pas2JS project something like LFM for the LCL project (DFM for VCL). But even more powerful because all the captions, texts and values get automatically replaced with XSLT. That allows me to fill pages, forms and tables with data with just 2 calls simple calls (JSON2XML+XSLT).
I add these XSLT files directly into the LPI project and add them to resources with:
{$R *.xslt}
{$R uFormContainerActions.xslt}
etc.
Now I have a lot of XSLT files in the project that I edit within Lazarus itself and it works well! (I don't need any external editor.)
This brings me to my problem:
I want to validate these XSLT files on compile - I want to write an extension for it.
What I want: when the XSLT is not valid (unclosed tag, invalid character, ... whatsoever), the compilation should be aborted and Lazarus should jump to the error position in XSLT.
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. 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.
Is it possible to extend the Pas2JS compiler with a DLL that hooks into the? {$R} handler? Or if not, is it possible to create some system to write own Pas2JS compiler extensions? Or do you have any other recommendations how to solve this?
Thanks
Ondrej
