I'm trying to cut down on my xml so that it's more short/compact, as requested by my team.
The format below winds up being about 1000 lines long with all my build processes, but I'm pretty sure there's a way to make it more compact. Is there a way to shorten the Condition or SuccessCriteria tag so that I use attributes like the surrounding xml? I need to account for cases with multiple conditions or SuccessCriteria, as shown below. From my search, same attribute pairs multiple times, it doesn't look like I can have attributes with the same name, which this would be if I do something similar to what I have in the top of the process tag.
I need the Condition name/value to always be called that because I'm using LINQ to read the xml and those conditions and success criteria get put in a list that I iterate through. Plus sometimes I have 1 condition pair, but sometimes it's 2, and in the future it could be 3. Similarly with SuccessCriteria.
<?xml version="1.0" encoding="UTF-8"?>
<BuildVerficationRoot>
<Configuration>
<Value Name="emailFrom">SCM-BuildCoordinator@co.com</Value>
<Value Name="admin_list">me@co.com</Value>
<Value Name="verboseLogFileName">VerifyBuildVerbose.txt</Value>
<Value Name="statsLogProcessVerFileName">ProcessStatusVerificationStats.txt</Value>
<Value Name="project">proj</Value>
<Value Name="version">1.0</Value>
</Configuration>
<BuildVerification>
<codeFreezeTime>19:00</codeFreezeTime>
<build machine="mach-1">
<Process name="Proc1"
startTimeHeader="StartTime"
endTimeHeader="EndTime"
failureColumns="ErrorDescription">
<Condition
name='VersionFile' value="\view\proj\filename1.cs">
</Condition>
<Condition
name='VersionFile' value="\view\proj\filename2.cs">
</Condition>
<SuccessCriteria>
<field>Status</field>
<comparison>equal</comparison>
<value>Success</value>
</SuccessCriteria>
</Process>
</build>
<build machine="co.net\share\folder\folder2\">
<Process name="Stats1"
startTimeHeader="Time"
endTimeHeader="Time"
failureColumns="">
<Condition
name='VersionId' value="1.0">
</Condition>
<Condition
name='MediaType' value="Incr">
</Condition>
<SuccessCriteria>
<field>Status</field>
<comparison>equal</comparison>
<value>Success</value>
</SuccessCriteria>
</Process>
<Process name="MediaStats"
startTimeHeader="EndTime"
endTimeHeader="EndTime"
failureColumns="">
<Condition
name1='Ver1' name2="Ver2">
</Condition>
<SuccessCriteria>
<field>MediaType</field>
<comparison>equal</comparison>
<value>Full</value>
</SuccessCriteria>
</Process>
<Process name="MediaStats"
startTimeHeader="EndTime"
endTimeHeader="EndTime"
failureColumns="">
<Condition
name1='Ver1' name2="Ver2">
</Condition>
<SuccessCriteria>
<field>MediaType</field>
<comparison>equal</comparison>
<value>Incr</value>
</SuccessCriteria>
</Process>
<Process name="ProcessingStats"
startTimeHeader="StartTime"
endTimeHeader="EndTime"
failureColumns="">
<Condition
name='Project' value="1.0">
</Condition>
<SuccessCriteria>
<field>Deliverables</field>
<comparison>notEqual</comparison>
<value>""</value>
</SuccessCriteria>
<SuccessCriteria>
<field>InInstallers</field>
<comparison>notEqual</comparison>
<value>""</value>
</SuccessCriteria>
<SuccessCriteria>
<field>MakePackage</field>
<comparison>notEqual</comparison>
<value>""</value>
</SuccessCriteria>
<SuccessCriteria>
<field>Publish</field>
<comparison>notEqual</comparison>
<value>""</value>
</SuccessCriteria>
</Process>
</build>
</BuildVerification>
</BuildVerficationRoot>
I tried doing the following with the first Process, but get error:
c# System.Xml>XmlException: "name" is a duplicate attribute name.
<Process name="SpinFileVersionStats"
startTimeHeader="StartTime"
endTimeHeader="EndTime"
failureColumns="ErrorDescription">
<Condition name='VersionFile' value="\view\proj\filename1.cs"
name='VersionFile2' value="\view\proj\filename2.cs"></Condition>
<SuccessCriteria>
<field>Status</field>
<comparison>equal</comparison>
<value>Success</value>
</SuccessCriteria>
</Process>
So my question is, is there a more compact way to show the same info in xml? I'm not talking about removing carriage returns around the Condition tags. Thanks!
XML attribute names must be unique per element in well-formed XML.
You can make your XML more compact and consistent by adjusting the element vs attribute design:
<Process name="Proc1"
startTimeHeader="StartTime"
endTimeHeader="EndTime"
failureColumns="ErrorDescription">
<Condition versionFile="\view\proj\filename1.cs"/>
<Condition versionFile="\view\proj\filename2.cs"/>
<SuccessCriteria field="Status"
comparison="equal"
value="Success"/>
</Process>
This design
name
attributes may
be written syntactically as XML attribute names directly.