Menu

validate xml with PMD

afont
2011-03-21
2020-07-23
  • afont

    afont - 2011-03-21

    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

     
  • Ankush Somani

    Ankush Somani - 2020-07-15

    @afont : were you able to validate xml files ?
    cc: @rgustav

     
    • Andreas Dangel

      Andreas Dangel - 2020-07-23

      @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

       

Log in to post a comment.