fast-xml-parser
fast-xml-parser copied to clipboard
[feature-request] Ignore validation for certain values
Description
It would be great if validator skipped certain expressions.
A case I noticed this could be useful is a framework that allows using javascript expressions as attribute values in XML. The format is usually like this:
<tagName value="5" text="{{ isVisible && isEditable }}"/>
<tagName value="5" text="{{ array.length > 5 }}"/>
As you can see, there is the case of using XML special characters for different functionality. I wonder if validator could be instructed to skip validation of attribute values using a regular expression.
I'm glad you find this repository helpful. I'll try to address your issue ASAP. You can watch the repo for new changes or star it.
I believe the only issue here is >, right?
I believe the only issue here is
>, right?
Thank you very much for your fast reply! It seems that none of them is the issue, though I wonder if validator should complain about both. Ampersand is also a special symbol and perhaps validator should not allow ampersand after ampersand. Regarding both cases, I didn't notice but I had also included quotes inside quotes in my own code and validator failed so I assumed it was special characters.
Validator can validate both cases.
Validator is not giving error for both of the examples currently. So, yes, it is a bug. And I believe it's quite easy to fix.
I'm leaving the bug open for sometimes, if someone want to try to fix it. Changes are required in validator.js:322. I believe current regular expression can't be fixed. So the function tagExpWithClosingIndex() from OrderedObjParser.js can be referred.
I'm even wondering if the validator code slowly can be merged to parser. :thinking: