Hi
I would like to use PMD to validate XML files. It´s possible?
I want to validate the existence of certain tags or properties of a xml
I read http://onjava.com/pub/a/onjava/2005/01/12/xpath.html but how-to merge mi parsing code with
PMD rule
Thanks in advance
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
In order to answer the OP question, we would need to clarify "validation": If you try to parse an invalid XML file, of course, you'll get a parse error. The parse error is reported in the PMD's output.
The XML file needs to be at least well-formed, so that rules can be executed against the XML file.
Hi
I would like to use PMD to validate XML files. It´s possible?
I want to validate the existence of certain tags or properties of a xml
I read http://onjava.com/pub/a/onjava/2005/01/12/xpath.html but how-to merge mi parsing code with
PMD rule
Thanks in advance
Trunk has support for XML, which should be able to accomplish what you want:
http://pmd.svn.sourceforge.net/viewvc/pmd/trunk/pmd/rulesets/xml/basic.xml?re
vision=7192&view=markup
Unit tests for this rule:
http://pmd.svn.sourceforge.net/viewvc/pmd/trunk/pmd/regress/test/net/sourcefo
rge/pmd/lang/xml/rule/basic/xml/MistypedCDATASection.xml?revision=7192&view=ma
rkup
@afont : were you able to validate xml files ?
cc: @rgustav
@ankushsomani09 You can see the rule documentation for XML here: https://pmd.github.io/latest/pmd_rules_xml.html
In order to answer the OP question, we would need to clarify "validation": If you try to parse an invalid XML file, of course, you'll get a parse error. The parse error is reported in the PMD's output.
The XML file needs to be at least well-formed, so that rules can be executed against the XML file.
You can write own rules either in Java or XPath: https://pmd.github.io/latest/pmd_userdocs_extending_writing_rules_intro.html