Wednesday, 13 March 2013

BizTalk : Custom XSLT to reomve empty node from XML request

Using XSLT to Remove Empty Node from request.
·         To implement this, we simply create one additional step in process/orchestration.
·         Add new map with Source schema same as destination schema.
·         Use the following custom XSLT code to scan the request and remove all empty node.

Map with same schema as request and response.

Use the following xslt file with your schema namespace.

<?xml version="1.0" ?>
<xsl:stylesheet xmlns:xsl="-- YOUR NAMESPACE --" version="1.0" xmlns:ns0="">
    <xsl:output method="xml" indent="yes" />
    <xsl:template match="node()">
        <xsl:if test="count(descendant::text()[string-length(normalize-space(.))>0]|@*)">
                <xsl:apply-templates select="@*|node()" />
    <xsl:template match="@*">
        <xsl:copy />
    <xsl:template match="text()">
        <xsl:value-of select="normalize-space(.)" />


Monday, 11 March 2013

Get the RegisteryKey value

Following sample code can be used to get RegisteryKey value based on keyPath and KeyName

public static String GetRegistryValue(String regKeyPath, String regKeyName)

// Create value variablestring regValue = null;
// Opening the registry keyRegistryKey rk = Registry.LocalMachine;
// Open a subKey as read-onlyRegistryKey regKey = rk.OpenSubKey(regKeyPath, RegistryKeyPermissionCheck.ReadSubTree, System.Security.AccessControl.RegistryRights.FullControl);
// If the RegistrySubKey does existif (regKey != null){

// If the RegistryKey exists get its value or null is returned.regValue = (string)regKey.GetValue(regKeyName.ToUpper());}

return regValue;}

catch (Exception ex){

throw ex;}

Read PublicKey from Assembly using sn.exe

To get PublicKey for assembly we need to use sn.exe SKD provided by microsoft.

Run a Visual Studio 2008/10 command prompt (Visual Studio Tool + Visual Studio 2008/10 Command Prompt from the “Start” menu).
  1. Enter the following command:
sn -Tp "C:/myassembly.dll"
Where “myassembly.dll” is the name of the signed assembly.

sn -Tp (assembly full path)

Regular Expression to remove non-printable character

Following simple regular expression can be used to reomve non-printable charcter from your string or data.

Code Sample :

string str = "342343\r\n24232234234234234";

Regex digitsOnly = new Regex(@"[\x00-\x1F]");str= digitsOnly.Replace(str,

ASCII code table