I am trying to parse the XML data from the output of cppcheck. But the XML structure seems wrong.
cppcheck src --enable=warning,style,unusedFunction --xml --inconclusive --std=posix --std=c++11 2> error_s.xml
cppcheck XML output:
<?xml version="1.0" encoding="UTF-8"?>
<results version="2">
<cppcheck version="1.82"/>
<errors>
<error id="funcArgNamesDifferent" severity="style" msg="Blah Blah bLah." verbose="Blah Blah Verbose" cwe="628" inconclusive="true">
<location file="src/DataLayer/ABC.cpp" line="329"/>
<location file0="src/DataLayer/ABC.cpp" file="src/DataLayer/ABC.h" line="64"/>
<location file0="src/DataLayer/ABC.cpp" file="src/DataLayer/ABC.h" line="64"/>
<location file0="src/DataLayer/ABC.cpp" file="src/DataLayer/ABC.h" line="64"/>
</error>
</errors>
</results>
Shouldn't the location node be inside an array like locations?
<locations>
<location file="src/DataLayer/ABC.cpp" line="329"/>
<location file0="src/DataLayer/ABC.cpp" file="src/DataLayer/ABC.h" line="64"/>
</locations>
unfortunately it cannot be accessed with out writting too many if-statements ..
if(isset($location)){
}
Conversation with CppChecker Developer.. Hopefully it would get fixed when they release v3
for now, the only way to access is using too many if-Statements.
if not, there is also library htmlreport which will generate html pages..
Related
We execute the following command line with heat (3.0.5210.0):
heat.exe -srd -suid file OurLib.dll -out bin_OurLib.tmp
OurLib.dll is a VC++ 2008 dll file, it's a COM component.
Output (bin_OurLib.tmp)
<?xml version="1.0" encoding="utf-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Fragment>
<DirectoryRef Id="TARGETDIR">
<Component Id="OurLib.dll" Guid="PUT-GUID-HERE">
<File Id="OurLib.dll" KeyPath="yes" Source="SourceDir\OurLib.dll">
<Class Id="{B1AB297C-1BC6-65E1-A7C1-A1833DFAED6A}" Context="InprocServer32" Description="OurProduct.OurLib">
<ProgId Id="OurProduct.OurLib" Description="OurProduct.OurLib" />
</Class>
</File>
</Component>
</DirectoryRef>
</Fragment>
</Wix>
This works fine.
Now we updated the VS to 2015, and compiled OurLib with it.
Running the same heat command now results in different output:
<?xml version="1.0" encoding="utf-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Fragment>
<DirectoryRef Id="TARGETDIR">
<Component Id="OurLib.dll" Guid="PUT-GUID-HERE">
<Class Id="{B1AB297C-1BC6-65E1-A7C1-A1833DFAED6A}" Context="InprocServer32" Description="OurProduct.OurLib">
<ProgId Id="OurProduct.OurLib" Description="OurProduct.OurLib" />
</Class>
<File Id="OurLib.dll" KeyPath="yes" Source="SourceDir\OurLib.dll" />
<RegistryValue Root="HKCR" Key="CLSID\{B1AB297C-1BC6-65E1-A7C1-A1833DFAED6A}\InProcServer32" Value=""[#OurLib.dll]"" Type="string" Action="write" />
</Component>
</DirectoryRef>
</Fragment>
</Wix>
And when wix is linking, it gives error:
error LGHT0130 : The primary key 'reg51A1FC16367511AF81E9B18CA009A1C6' is duplicated in table 'Registry'. Please remove one of the entries or rename a part of the primary key to avoid the collision.
Checking the wixobj file, reg51A1FC16367511AF81E9B18CA009A1C6 is related to line
<Class Id="{B1AB297C-1BC6-65E1-A7C1-A1833DFAED6A}...." and <RegistryValue Root="HKCR" Key="CLSID\{B1AB.... - obviously.
Anwyay, this is obviously due to the generated wix output files are different.
Why is that if compiling a dll with a newer C++ compiler will cause WIX HEAT to generate different output, while running the same options, etc.
And how can I have back the same "old" output, which we need.
Tried with -scom and -sreg, none of them gave back the "old" output.
Well primary key duplicated means you've got that same RegistryValue in two different places in your wix source code somehow.
Or maybe the newer DLL is self-registering differently? It's putting the InProcServer32 value in quotes. I don't think that's normal.
Or have you checked that your 2008 and 2015 DLL source and project files are identical? The VS project upgrade process changes things...
I created Settings.FSharpLint and I want to suppress IdentifiersMustNotContainUnderscores rule
Is it possible to disable only one rule?
Example (Doesn't work):
<?xml version="1.0" encoding="utf-8"?>
<FSharpLintSettings>
<Analysers>
<NameConventions>
<IdentifiersMustNotContainUnderscores>
<Enabled>False</Enabled>
</IdentifiersMustNotContainUnderscores>
</NameConventions>
</Analysers>
</FSharpLintSettings>
I tried this and it worked well (But it's for all NameConventions rules):
<?xml version="1.0" encoding="utf-8"?>
<FSharpLintSettings>
<Analysers>
<NameConventions>
<Enabled>False</Enabled>
</NameConventions>
</Analysers>
</FSharpLintSettings>
The IdentifiersMustNotContainUnderscores element needs to be nested inside a Rules element, try:
<?xml version="1.0" encoding="utf-8"?>
<FSharpLintSettings>
<Analysers>
<NameConventions>
<Rules>
<IdentifiersMustNotContainUnderscores>
<Enabled>False</Enabled>
</IdentifiersMustNotContainUnderscores>
</Rules>
</NameConventions>
</Analysers>
</FSharpLintSettings>
I am trying to transform a JSON response from a target end point into soap message. I have 2 policies in the post flow.
JSONTOXML - If I disable xsltransform I see the xml result so this work.
xsltransform - this just point to my xsltransform file which has the template and dynamic content supposed to come from the xml from step 1.
Both source and output are set to "response" but it looks like it failed to cast in step 2. What should I make step 2 to pick up the xml and apply the xsl? How else can I do this? Thanks
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<JSONToXML async="false" continueOnError="false" enabled="true" name="jsontoxml-2">
<DisplayName>JSONtoXML-2</DisplayName>
<FaultRules/>
<Properties/>
<Options>
<NullValue>NULL</NullValue>
<NamespaceBlockName>#namespaces</NamespaceBlockName>
<DefaultNamespaceNodeName>$default</DefaultNamespaceNodeName>
<NamespaceSeparator>:</NamespaceSeparator>
<TextNodeName>#text</TextNodeName>
<AttributeBlockName>#attrs</AttributeBlockName>
<AttributePrefix>#</AttributePrefix>
<InvalidCharsReplacement>_</InvalidCharsReplacement>
<ObjectRootElementName>Root</ObjectRootElementName>
<ArrayRootElementName>Array</ArrayRootElementName>
<ArrayItemElementName>Item</ArrayItemElementName>
</Options>
<OutputVariable>response</OutputVariable>
<Source>response</Source>
</JSONToXML>
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<XSL async="false" continueOnError="false" enabled="true" name="xsltransform-1">
<DisplayName>XSLTransform-1</DisplayName>
<FaultRules/>
<Properties/>
<Source>response</Source>
<ResourceURL>xsl://xsltransform-1</ResourceURL>
<Parameters ignoreUnresolvedVariables="true"/>
<OutputVariable>response</OutputVariable>
</XSL>
OutputVariable cannot be set to 'response'.
Try removing the 'OutputVariable' line, or leaving it empty. Removing it, should cause the output to go to the response payload.
In other words, try this:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<XSL async="false" continueOnError="false" enabled="true" name="xsltransform-1">
<DisplayName>XSLTransform-1</DisplayName>
<FaultRules/>
<Properties/>
<Source>response</Source>
<ResourceURL>xsl://xsltransform-1</ResourceURL>
<Parameters ignoreUnresolvedVariables="true"/>
</XSL>
Is this always the case? Can OutputVariable never be set on response?
I would like to count the number of items that match the following conditions:
/results/errors/error/[#severity='warning']
and
test="not(string-length(substring-before(/results/errors/error/location/#file,'cow'))=0)"
So, while my first condition can easily be counted by using the built in count function
count(//results/errors/error[#severity='warning'])
I do not know how to use the count function for the second condition, as it is not in Xpath format.
Any help you can provide to me would be greatly appreciated. (My XML is below)
The desired answer would be: 2
Thank you,
Belinda
My xml looks like this:
<results version="2">
<errors>
<error id="redundantAssignment" severity="performance" msg="blah, blah.">
<location file="/farm/user/cow/src/IO/file1.cpp"/>
<location file="/farm/user/horse//src/IO/file5.cpp"/>
</error>
<error id="redundantAssignment" severity="warning" msg="blah, blah.">
<location file="/farm/user/sheep/src/IO/file1.cpp"/>
<location file="/farm/user/cow/src/IO/file2.cpp"/>
</error>
<error id="redundantAssignment" severity="error" msg="blah, blah.">
<location file="/farm/user/horse/src/IO/file1.cpp"/>
<location file="/farm/user/cow//src/IO/file3.cpp"/>
</error>
<error id="redundantAssignment" severity="warning" msg="blah, blah.">
<location file="/farm/user/sheep/src/IO/file1.cpp"/>
<location file="/farm/user/cow/src/IO/file3.cpp"/>
</error>
<error id="redundantAssignment" severity="warning" msg="blah, blah.">
<location file="/farm/user/sheep/src/IO/file1.cpp"/>
<location file="/farm/user/horse/src/IO/file3.cpp"/>
</error>
<error id="redundantAssignment" severity="style" msg="blah, blah.">
<location file="/farm/user/sheep/src/IO/file1.cpp"/>
<location file="/farm/user/horse/src/IO/file4.cpp"/>
</error>
<error id="redundantAssignment" severity="style" msg="blah, blah.">
<location file="/farm/user/sheep/src/IO/file1.cpp"/>
<location file="/farm/user/horse/src/IO/file2.cpp"/>
</error>
</errors>
</results>
You should be able to combine both into a single count() by adding the second test to the first predicate:
count(/results/errors/error[#severity='warning' and location[not(string-length(substring-before(#file,'cow'))=0)]])
Using your sample XML input, this produces 2.
Simplification using contains() suggested by Tim C...
count(/results/errors/error[#severity='warning' and location[contains(#file,'cow')]])
I am attempting to get xincludes working in an existing system that uses a XercesDOMParser in xercesc to parse incoming xml from a client. I am working with Apache Xercesc v3.0.1, and the incoming XML, read from an input stream, is:
<?xml version="1.0" encoding="UTF-8"?>
<VisionServer xmlns:xi="http://www.w3.org/2001/XInclude">
<CompositeObject>
<xi:include href="testguioutput.xml" />
while testguioutput.xml contains
<?xml version="1.0" encoding="UTF-8"?>
<GUIOutput>
<Input>Input</Input>
<Title>IDC2_1</Title>
</GUIOutput>
The existing code uses a wrapper around a XercesDOMParser to parse the XML as it comes in, and after using setDoNamespaces and setDoXInclude to true, it is attempting to parse the XInclude, but I get a persistent "Fatal: include failed and no fallback element found in document '{0}'" error, no matter where in the directory structure I put testguioutput.xml.
I am working under visualstudio 2008, my working directory is default, and running out of /project/debug, but the include fails whether the target file is in /project/ or /project/debug/.
I was able to expand the xinclude tags using the XInclude.exe sample application that is included with the Xerces application. To do this, I created two files using your files above:
test1.xml:
<?xml version="1.0" encoding="UTF-8"?>
<VisionServer xmlns:xi="http://www.w3.org/2001/XInclude">
<CompositeObject>
<xi:include href="test2.xml"/>
</CompositeObject>
</VisionServer>
test2.xml:
<?xml version="1.0" encoding="UTF-8"?>
<GUIOutput>
<Input>Input</Input>
<Title>IDC2_1</Title>
</GUIOutput>
At the command line I executed:
"XInclude.exe test1.xml test1_expanded.xml" without quotes.
The resulting test1_expanded.xml file:
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<VisionServer xmlns="" xmlns:xi="http://www.w3.org/2001/XInclude">
<CompositeObject>
<GUIOutput xml:base="test2.xml">
<Input>Input</Input>
<Title>IDC2_1</Title>
</GUIOutput>
</CompositeObject>
</VisionServer>