SYNTAX HIGHLIGHTER BEGINS

Wednesday, December 10, 2008

My new HTPC

Ok I just created a new HTPC (Home Theater PC) and let me just say how the hell did I live with out this before. I actually was able to drop my Dish Network service since most of what I was watching is offered online.
When I get a chance I hope to list everything I went thru in creating it.

Tuesday, September 9, 2008

.net Exception list

Jeff Atwood wrote a great little block of code to list all the exceptions in .net. I just needed the most common ones so I posted them here.

System.AppDomainUnloadedException
System.ApplicationException
System.ArgumentException
System.ArgumentNullException
System.ArgumentOutOfRangeException
System.ArithmeticException
System.ArrayTypeMismatchException
System.BadImageFormatException
System.CannotUnloadAppDomainException
System.ComponentModel.Design.CheckoutException
System.ComponentModel.Design.Serialization.CodeDomSerializerException
System.ComponentModel.InvalidEnumArgumentException
System.ComponentModel.LicenseException
System.ComponentModel.WarningException
System.ComponentModel.Win32Exception
System.Configuration.ConfigurationException
System.ContextMarshalException
System.Data.ConstraintException
System.Data.DataException
System.Data.DBConcurrencyException
System.Data.DeletedRowInaccessibleException
System.Data.DuplicateNameException
System.Data.EvaluateException
System.Data.ExprException
System.Data.InRowChangingEventException
System.Data.InvalidConstraintException
System.Data.InvalidExpressionException
System.Data.MissingPrimaryKeyException
System.Data.NoNullAllowedException
System.Data.Odbc.OdbcException
System.Data.OleDb.OleDbException
System.Data.ReadOnlyException
System.Data.RowNotInTableException
System.Data.SqlClient._ValueException
System.Data.SqlClient.SqlException
System.Data.SqlTypes.SqlNullValueException
System.Data.SqlTypes.SqlTruncateException
System.Data.SqlTypes.SqlTypeException
System.Data.StrongTypingException
System.Data.SyntaxErrorException
System.Data.TypedDataSetGeneratorException
System.Data.VersionNotFoundException
System.DivideByZeroException
System.DllNotFoundException
System.Drawing.Printing.InvalidPrinterException
System.DuplicateWaitObjectException
System.EntryPointNotFoundException
System.Exception
System.ExecutionEngineException
System.FieldAccessException
System.FormatException
System.IndexOutOfRangeException
System.InvalidCastException
System.InvalidOperationException
System.InvalidProgramException
System.IO.DirectoryNotFoundException
System.IO.EndOfStreamException
System.IO.FileLoadException
System.IO.FileNotFoundException
System.IO.InternalBufferOverflowException
System.IO.IOException
System.IO.IsolatedStorage.IsolatedStorageException
System.IO.PathTooLongException
System.Management.ManagementException
System.MemberAccessException
System.Messaging.MessageQueueException
System.MethodAccessException
System.MissingFieldException
System.MissingMemberException
System.MissingMethodException
System.MulticastNotSupportedException
System.Net.CookieException
System.Net.ProtocolViolationException
System.Net.Sockets.SocketException
System.Net.WebException
System.NotFiniteNumberException
System.NotImplementedException
System.NotSupportedException
System.NullReferenceException
System.ObjectDisposedException
System.OutOfMemoryException
System.OverflowException
System.PlatformNotSupportedException
System.RankException
System.Reflection.AmbiguousMatchException
System.Reflection.CustomAttributeFormatException
System.Reflection.InvalidFilterCriteriaException
System.Reflection.ReflectionTypeLoadException
System.Reflection.TargetException
System.Reflection.TargetInvocationException
System.Reflection.TargetParameterCountException
System.Resources.MissingManifestResourceException
System.Runtime.InteropServices.COMException
System.Runtime.InteropServices.ExternalException
System.Runtime.InteropServices.InvalidComObjectException
System.Runtime.InteropServices.InvalidOleVariantTypeException
System.Runtime.InteropServices.MarshalDirectiveException
System.Runtime.InteropServices.SafeArrayRankMismatchException
System.Runtime.InteropServices.SafeArrayTypeMismatchException
System.Runtime.InteropServices.SEHException
System.Runtime.Remoting.MetadataServices.SUDSGeneratorException
System.Runtime.Remoting.MetadataServices.SUDSParserException
System.Runtime.Remoting.RemotingException
System.Runtime.Remoting.RemotingTimeoutException
System.Runtime.Remoting.ServerException
System.Runtime.Serialization.SerializationException
System.Security.Cryptography.CryptographicException
System.Security.Cryptography.CryptographicUnexpectedOperationException
System.Security.Policy.PolicyException
System.Security.SecurityException
System.Security.VerificationException
System.Security.XmlSyntaxException
System.ServiceProcess.TimeoutException
System.StackOverflowException
System.SystemException
System.Threading.SynchronizationLockException
System.Threading.ThreadAbortException
System.Threading.ThreadInterruptedException
System.Threading.ThreadStateException
System.Threading.ThreadStopException
System.TypeInitializationException
System.TypeLoadException
System.TypeUnloadedException
System.UnauthorizedAccessException
System.UriFormatException
System.Web.HttpApplication+CancelModuleException
System.Web.HttpCompileException
System.Web.HttpException
System.Web.HttpParseException
System.Web.HttpRequestValidationException
System.Web.HttpUnhandledException
System.Web.Services.Discovery.InvalidContentTypeException
System.Web.Services.Discovery.InvalidDocumentContentsException
System.Web.Services.Protocols.SoapException
System.Web.Services.Protocols.SoapHeaderException
System.Windows.Forms.AxHost+InvalidActiveXStateException
System.Xml.Schema.XmlSchemaException
System.Xml.XmlException
System.Xml.XPath.XPathException
System.Xml.Xsl.XsltCompileException
System.Xml.Xsl.XsltException

Wednesday, July 9, 2008

Xsl function to testing if text only contains footnote marks

The situation come up were I had a table of data and in on of the columns it had just footnote marks. Well I had to merge these footnote marks over to the previous column, but in order to do this I needed to know if the only value in the cell were marks. So I realize there are many ways to do this but I thought this was a cool way. It reads in an external xml file with all the footnote refs I want to search for the ref value is a regex.
<footnotes>
<footnote ref="\*"/>
<footnote ref="\+"/>
<footnote ref="†"/>
<footnote ref="\([a-z]\)"/>
<footnote ref="\([1-9]\)"/>
</footnotes>

I then concat the refs together with a | and do a replace on the string value. If nothing is left then it is a footnote ref.


<!-- Reads all possible footnote ref marks from a footnotes.xml file and if pText only contains footnote marks returns true otherwise false -->
<xsl:function name="txt:IsFootnoteRef" as="xs:boolean">
<xsl:param name="pText" as="xs:string"/>
<xsl:variable name="vFootnotes" select=" document('./footnotes.xml')/footnotes/footnote"/>
<xsl:choose>
<xsl:when test="not($vFootnotes)">
<xsl:value-of select="false()"/>
</xsl:when>
<xsl:when test="not($pText)">
<xsl:value-of select="false()"/>
</xsl:when>
<xsl:when test="normalize-space($pText) = '' ">

<xsl:value-of select="false()"/>
</xsl:when>
<xsl:otherwise>
<xsl:variable name="vFootnoteRef">
<xsl:value-of select="$vFootnotes/@ref" separator="|"/>
</xsl:variable>

<xsl:choose>
<xsl:when test=" normalize-space(replace($pText, $vFootnoteRef , '' , 'i')) = '' ">
<xsl:value-of select="true()"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="false()"/>
</xsl:otherwise>
</xsl:choose>
</xsl:otherwise>
</xsl:choose>
</xsl:function>

Tuesday, March 4, 2008

Comparing XML attributes with parents attributes

I had a need to test if all/most of the attributes of a child node were equal to its parent and strip out the child node if true.

My XML structure was basically:

<PARAGRAPH style='heading1' emphasis='true' font='arial' number='30' indent=’10’>

<SPECIALTEXT style='heading1' emphasis='true' font='arial' number='31'>

Helloworld

</SPECIALTEXT>

</PARAGRAPH>

Output needed to be:

<PARAGRAPH style='heading1' emphasis='true' font='arial' number='30'>

Helloworld

</PARAGRAPH>

Now this only works on the first level after the PARAGRAPH but that’s all I needed, and it could be changed to do this recursively I guess. Basically I am matching on any paragraph that contains a child element SPECIALTEXT with the same style attribute and calling the template CompareKeyAttributes.
PARAGRAPH has more attributes than SPECIALTEXT in most cases so I compare only the ones that exist in SPECIALTEXT.

CompareKeyAttributes will return a string of all the
attributes that don’t match so then I just check if I care that the attribute
is different and output accordingly.

<xsl:template match="PARAGRAPH[SPECIALTEXT[@Style=./@Style] ] ">

<xsl:copy>

<xsl:apply-templates select="@*"/>

<xsl:for-each select=" child::*">

<xsl:variable name="RESULT">

<xsl:call-template name="CompareKeyAttributes">

<xsl:with-param name="PARA" select=".."/>

<xsl:with-param name="SPEC" select="."/>

</xsl:call-template>

</xsl:variable>

<xsl:choose>

<xsl:whentest="$RESULT='number' ">

<xsl:apply-templates select="child::node()"/>

</xsl:when>

<xsl:otherwise>

<xsl:copy>

<xsl:apply-templates select="@*|node()"/>

</xsl:copy>

</xsl:otherwise>

</xsl:choose>

</xsl:for-each>

</xsl:copy>

</xsl:template>

<xsl:template name="CompareKeyAttributes">

<xsl:param name="PARA"/>

<xsl:param name="SPEC"/>

<xsl:for-each select="$SPEC/@*">

<xsl:variable name="SPEC_ATT" select="name()"/>

<xsl:variable name="PARA_ATT" select="$PARA/@*[name()= $SPEC_ATT]"/>

<xsl:choose>

<xsl:when test="$PARA_ATT != .">

<xsl:value-of select="name()"/>

</xsl:when>

</xsl:choose>

</xsl:for-each>

</xsl:template>

Let me know if you find this useful or have anyway to make it better. Enjoy

Tuesday, February 19, 2008

Upgrading MOSS2007 to SP1

Jason had some good references for upgrading MOSS07 to SP1. I have tried the upgrade on my development server with out any issues, but that is a single server env. I will try the upgrade next week on QA servers but anyway here is the link http://blogs.informationhub.com/jnadrowski/archive/2008/01/11/24045.aspx

Wednesday, January 2, 2008

Changing Virtual Hard Drive from IDE to SCSI

Well I created virtual server with a single Virtual IDE hard drive (VHD) that ran out of space so I decided I was going to find a way to enlarge it and also switch to SCSI, because I read it was better performing. Well I found alot of post about expanding the hard drive and I will post the details of that in another post.

Here I want to post the steps to switching to a SCSI drive.


  1. Open the Virtual Server Web Administration site and select configure your specific Virtual Machine
  2. In the Virtual Machine Configuration windows, select Add SCSI Adapter ID 7
  3. Make sure you leave your boot disk as IDE disk
  4. Start your virtual machine
  5. You should see the following when the adapter is registered "Adaptec AIC-7870 PCI SCSI Adapter". The virtual machine will now be able to boot with SCSI but this SCSI driver is very slow.
  6. Right-click on the Adaptec driver and select Update Driver
  7. Choose the Install from a list or specific location and Have Disk options
  8. Browse to the C:\Program Files\Virtual Machine Additions folder and click OK
  9. The Microsoft Virtual Machine PCI SCSI Controller driver should now be installed
  10. Shutdown your virtual machine
  11. In the Virtual Server Virtual Machine configuration select hard disks in the configuration section
  12. Change your boot hard disk to the SCSI ID 0
  13. Click OK
  14. Start the virtual machine
good luck and remember backups..