Bug with xml output from vault client

If you are having a problem using Vault, post a message here.

Moderator: SourceGear

Post Reply
mballou
Posts: 18
Joined: Fri Apr 15, 2005 6:46 pm

Bug with xml output from vault client

Post by mballou » Mon May 15, 2006 5:44 pm

Oops-- Please ignore this post. After much testing, I finally realized it was my build script tool that is somehow re-parsing the xml output and converting it to apostrophes.


I'm running the History command from the vault client, and the output it gives is not valid xml.

The problem is that one of the comments in the history contains an apostrophe ('), which is not xml encoded.

<item txid='225751' date='5/15/2006 11:26:30 AM' name='_Mainline/File.cpp' type='60' version='58' user='abc' comment='Can't use apostrophe' actionString='Checked In' />

The apostrophe in the word "can't" causes the problem. I'm also using the VaultClient API which has code for a client utility. I noticed the comment in there about using a custom XmlOutputWriter.

Thanks,
Mike Ballou
Last edited by mballou on Mon May 15, 2006 7:21 pm, edited 1 time in total.

mballou
Posts: 18
Joined: Fri Apr 15, 2005 6:46 pm

Post by mballou » Mon May 15, 2006 6:58 pm

I converted the sample code using the custom XMLOutputWriter class to use the standard Microsoft XmlTextWriter class and the output results are the same excect it properly handles the xml encoding. It was pretty simple. Here are the steps I did:

Add System.xml.dll reference
Add "using System.Xml" to top of VaultCmdLineClient.cs and Help.cs

Make following replacements:
XMLOutputWriter -> XmlTextWriter
WriteUserMessage -> WriteComment()
AddPair -> WriteAttributeString() - Need to convert some values to string with .ToString(). for bools add ? "yes" : "no"
Begin -> WriteStartElement()
End -> WriteEndElement()
WriteContent -> WriteString()
cmdlineargs.Out.WriteLine("<vault>"); -> xml.WriteStartElement("vault");
cmdlineargs.Out.WriteLine("</vault>"); -> xml.WriteEndElement();

In Main() replace creation of XMLOutputWriter with these 4 lines:
XmlTextWriter xml = new XmlTextWriter(cmdlineargs.Out);
xml.Indentation = 1;
xml.IndentChar = '\t';
xml.Formatting = Formatting.Indented;

mballou
Posts: 18
Joined: Fri Apr 15, 2005 6:46 pm

Post by mballou » Mon May 15, 2006 7:22 pm

I edited my original post. I just realized my build script is somehow corrupting the xml output. The vault command line had the proper xml output already which didn't have a problem with the apostrophes.

Post Reply