You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
org.xml.sax.SAXParseException; lineNumber: 4; columnNumber: 23; Open quote is expected for attribute "nav-items" associated with an element type "ui-navbar".
It's not a valid XML format, e.g.
<ui-navbarnav-items={navigationItems} ...
should be
<ui-navbarnav-items="{navigationItems}" ...
These curly braces look like this is actually a template (also the "if:true" pseudo attributes later on) and the "XML" is probably not used as-is.
We would need to preprocess it if we want to use the standard XML parser or would need to write an own parser.
Preprocessing has the downside, that the analysis happens not on the original source, and it could introduce other errors.
@adangel thanks for looking into this. So there is still something in this world like not well-formed HTML.
I know Salesforce LWC is following industry Web Components standards and had hoped this mean well-formed XML. But no...
Can you elaborate a bit on why PMD never supported HTML? Because there exist no compatible parsers or because nobody contributed it or what else?
I asked in salesforce/lwc#2749 which format they use and if there is a public parser?
I had a look a https://jsoup.org/ - this is a lot more relaxed for parsing. I could successfully parse the snippet you mentioned via Parser.xmlParser().parseInput(...). Like the DOM from plain java xml, this DOM also doesn't support positional info. But we had created a solution back then already (which involves going through the file once more): DOMLineNumbers
For PMD 7 I wrote a javadoc parser, which as you know includes HTML. This supports position information correctly, maybe we could extract it. I like Jsoup, but its API also allows mutating everything, which PMD rules shouldn't be doing.
Activity
[-]PMD to parse and analyse Salesforce LWC markup[/-][+]Support Salesforce LWC Markup[/+]adangel commentedon Mar 17, 2022
The error message is:
It's not a valid XML format, e.g.
should be
These curly braces look like this is actually a template (also the "if:true" pseudo attributes later on) and the "XML" is probably not used as-is.
We would need to preprocess it if we want to use the standard XML parser or would need to write an own parser.
Preprocessing has the downside, that the analysis happens not on the original source, and it could introduce other errors.
In the documentation they use "HTML" for the description of this format: https://developer.salesforce.com/docs/component-library/documentation/en/lwc/lwc.create_components_html
"A template is valid HTML with a root tag."
But HTML is not supported by PMD today (#3521).
rsoesemann commentedon Mar 17, 2022
@adangel thanks for looking into this. So there is still something in this world like not well-formed HTML.
I know Salesforce LWC is following industry Web Components standards and had hoped this mean well-formed XML. But no...
Can you elaborate a bit on why PMD never supported HTML? Because there exist no compatible parsers or because nobody contributed it or what else?
I asked in salesforce/lwc#2749 which format they use and if there is a public parser?
adangel commentedon Mar 18, 2022
Yes, nobody contributed.
I had a look a https://jsoup.org/ - this is a lot more relaxed for parsing. I could successfully parse the snippet you mentioned via
Parser.xmlParser().parseInput(...). Like the DOM from plain java xml, this DOM also doesn't support positional info. But we had created a solution back then already (which involves going through the file once more): DOMLineNumbersoowekyala commentedon Mar 18, 2022
For PMD 7 I wrote a javadoc parser, which as you know includes HTML. This supports position information correctly, maybe we could extract it. I like Jsoup, but its API also allows mutating everything, which PMD rules shouldn't be doing.
niteshCopado commentedon Mar 6, 2024
Hi @rsoesemann @adangel Will there be a plan for PMD to support LWC?