Menu

Wrong XML Structure

2020-07-01
2020-07-02
  • zubair Shaik

    zubair Shaik - 2020-07-01

    Hi There,

    Iam trying to parse the xml data from the output of cppcheck.. But the XML structure seems wrong..

    XSD

           <error id="funcArgNamesDifferent" severity="style" msg="Function &apos;f&apos; argument 1 names different: declaration &apos;data&apos; definition &apos;x&apos;." verbose="Function &apos;f&apos; argument 1 names different: declaration &apos;data&apos; definition &apos;x&apos;." cwe="628" inconclusive="true">
                <location file="file1.cpp" line="2"/>
                <location file0="file1.cpp" file="file1.h" line="1"/>
                <symbol>f</symbol>
            </error>
    

    but shouldnt the location node be an Array..??

           <error id="funcArgNamesDifferent" severity="style" msg="Function &apos;f&apos; argument 1 names different: declaration &apos;data&apos; definition &apos;x&apos;." verbose="Function &apos;f&apos; argument 1 names different: declaration &apos;data&apos; definition &apos;x&apos;." cwe="628" inconclusive="true">
           <locations>
                <location file="file1.cpp" line="2"/>
                <location file0="file1.cpp" file="file1.h" line="1"/>
            </location>
                <symbol>f</symbol>
            </error>
    
     

    Last edit: zubair Shaik 2020-07-01
  • anoy.

    anoy. - 2020-07-01

    Why should it? Even the linked validation schema shows that there can be zero or more occurences of <location>. Xml doesn't need an enclosing element for 'arrays', like e.g. Json does.

    I've parsed it successfully, written xsl styles (to HTML) for it and our used Jenkins plugin also can parse it.


    How are you trying to parse it? Maybe showing your implementation could help.

     

    Last edit: anoy. 2020-07-01
  • Daniel Marjamäki

    Yes it is valid XML. It would probably be better to separate the locations as you suggest but I do not want to break the xml format since there are lots of tools and scripts that use it.

     
  • zubair Shaik

    zubair Shaik - 2020-07-02

    @anoy why should it be..? because its called Object Oriented programming... it shows valid XML because it only does basic checks for validaty.. I

    @DanielMarjamäki:
    Okay i understand.. would you be considering perhaps for the next Version..?

    I checked out HtmlReport i see too many if statements whcih i really wanted to avoid...

     
  • Daniel Marjamäki

    If we ever need to change the xml format we can add a --xml-version=3 option.. but well I do not believe there is a strong reason for that right now. If that is added then --xml-version=2 will continue to be used default for a couple of years.. so people have time to update their tools and scripts. So when we invent a new xml format we will have 2 xml format outputs in our code for years.

    If we add a new xml format .. HtmlReport should handle both --xml-version=2 and --xml-version=3 output so I imagine that script will become more complex. The HtmlReport even handles version 1.. I believe we removed that format from cppcheck a few years ago so it can be removed from HtmlReport also.

     
  • zubair Shaik

    zubair Shaik - 2020-07-02

    @DanielMarjamäki:

    yes, --xml-version=3 would be really helpful. I have many xml from which I do parsing and get the results into the db... untill the version 3 is released i will do with the if-Statements though it makes the overall import process slower.

    Please do keep this in the bucket list for Version 3.

    Thanks for the support. I really appreciate.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.