Click here to Skip to main content
15,883,883 members
Articles / Containers / Virtual Machine

BizTalk The Practical Course Code

Rate me:
Please Sign up or sign in to vote.
4.78/5 (7 votes)
24 Apr 2009CPOL27 min read 50.5K   743   24  
Code Sample and a sample chapter from Book BizTalk The Practical Course
namespace BTSPracCourse.Maps.Samples {
    
    
    [Microsoft.XLANGs.BaseTypes.SchemaReference(@"BTSPracCourse.Schemas.Sample.NewsML", typeof(BTSPracCourse.Schemas.Sample.NewsML))]
    [Microsoft.XLANGs.BaseTypes.SchemaReference(@"BTSPracCourse.Schemas.Sample.NewsML", typeof(BTSPracCourse.Schemas.Sample.NewsML))]
    public sealed class OutputNodesConditionalMap : Microsoft.XLANGs.BaseTypes.TransformBase {
        
        private const string _strMap = @"<?xml version=""1.0"" encoding=""UTF-16""?>
<xsl:stylesheet xmlns:xsl=""http://www.w3.org/1999/XSL/Transform"" xmlns:msxsl=""urn:schemas-microsoft-com:xslt"" xmlns:var=""http://schemas.microsoft.com/BizTalk/2003/var"" exclude-result-prefixes=""msxsl var userCSharp"" version=""1.0"" xmlns:ns0=""http://www.MoustafaRefaat.com/BTSPracCourseSchemas/NewsSchema"" xmlns:userCSharp=""http://schemas.microsoft.com/BizTalk/2003/userCSharp"">
  <xsl:output omit-xml-declaration=""yes"" method=""xml"" version=""1.0"" />
  <xsl:template match=""/"">
    <xsl:apply-templates select=""/ns0:NewsML"" />
  </xsl:template>
  <xsl:template match=""/ns0:NewsML"">
    <ns0:NewsML>
      <xsl:for-each select=""NewsItem"">
        <xsl:variable name=""var:v1"" select=""userCSharp:LogicalEq(string(Identification/NewsIdentifier/ns0:ProviderId/text()) , &quot;&quot;CP&quot;&quot;)"" />
        <xsl:if test=""$var:v1"">
          <NewsItem>
            <Identification>
              <NewsIdentifier>
                <ns0:RevisionId>
                  <xsl:attribute name=""PreviousRevision"">
                    <xsl:text>0</xsl:text>
                  </xsl:attribute>
                  <xsl:attribute name=""Update"">
                    <xsl:text>N</xsl:text>
                  </xsl:attribute>
                </ns0:RevisionId>
              </NewsIdentifier>
            </Identification>
          </NewsItem>
        </xsl:if>
      </xsl:for-each>
      <xsl:value-of select=""./text()"" />
    </ns0:NewsML>
  </xsl:template>
  <msxsl:script language=""C#"" implements-prefix=""userCSharp""><![CDATA[
public bool LogicalEq(string val1, string val2)
{
	bool ret = false;
	double d1 = 0;
	double d2 = 0;
	if (IsNumeric(val1, ref d1) && IsNumeric(val2, ref d2))
	{
		ret = d1 == d2;
	}
	else
	{
		ret = String.Compare(val1, val2, StringComparison.Ordinal) == 0;
	}
	return ret;
}


public bool IsNumeric(string val)
{
	if (val == null)
	{
		return false;
	}
	double d = 0;
	return Double.TryParse(val, System.Globalization.NumberStyles.AllowThousands | System.Globalization.NumberStyles.Float, System.Globalization.CultureInfo.InvariantCulture, out d);
}

public bool IsNumeric(string val, ref double d)
{
	if (val == null)
	{
		return false;
	}
	return Double.TryParse(val, System.Globalization.NumberStyles.AllowThousands | System.Globalization.NumberStyles.Float, System.Globalization.CultureInfo.InvariantCulture, out d);
}


]]></msxsl:script>
</xsl:stylesheet>";
        
        private const string _strArgList = @"<ExtensionObjects />";
        
        private const string _strSrcSchemasList0 = @"BTSPracCourse.Schemas.Sample.NewsML";
        
        private const BTSPracCourse.Schemas.Sample.NewsML _srcSchemaTypeReference0 = null;
        
        private const string _strTrgSchemasList0 = @"BTSPracCourse.Schemas.Sample.NewsML";
        
        private const BTSPracCourse.Schemas.Sample.NewsML _trgSchemaTypeReference0 = null;
        
        public override string XmlContent {
            get {
                return _strMap;
            }
        }
        
        public override string XsltArgumentListContent {
            get {
                return _strArgList;
            }
        }
        
        public override string[] SourceSchemas {
            get {
                string[] _SrcSchemas = new string [1];
                _SrcSchemas[0] = @"BTSPracCourse.Schemas.Sample.NewsML";
                return _SrcSchemas;
            }
        }
        
        public override string[] TargetSchemas {
            get {
                string[] _TrgSchemas = new string [1];
                _TrgSchemas[0] = @"BTSPracCourse.Schemas.Sample.NewsML";
                return _TrgSchemas;
            }
        }
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Architect
Canada Canada
As a well-established IT leader with a passion for architecture, design, coding, refactoring, and development, I possess 20+ years’ success spearheading large teams to deliver the end-to-end development of 30+ innovative software solutions on time and under budget on a US and international level.

Throughout my career, I have made it my priority to utilize current technologies and new techniques to develop elegant, creative technical solutions across all project phases. Comfortable in collaborative and independently-driven roles, I am a forward-thinking leader with refined analytical and critical thinking skills, and I can adapt and revise my strategies to meet evolving priorities, shifting needs, and emergent issues. As a dynamic leader with experience as Technical Lead and Senior Manager, as well as on the Board of Directors, I have led numerous teams to create a new employees experience with Workday, roadmap for people systems (JDA WFMR, Kronos, Infor, Workday, and monitoring with Splunk), and architecture for 20+ projects at Loblaw. Furthermore, I have spearheaded As a well-established IT leader with a passion for architecture, design, coding, refactoring, and development, I possess 20+ years’ success spearheading large teams to deliver the end-to-end development of 30+ innovative software solutions on time and under budget on a US and international level.

Throughout my career, I have made it my priority to utilize current technologies and new techniques to develop elegant, creative technical solutions across all project phases. Comfortable in collaborative and independently-driven roles, I am a forward-thinking leader with refined analytical and critical thinking skills, and I can adapt and revise my strategies to meet evolving priorities, shifting needs, and emergent issues. As a dynamic leader with experience as Technical Lead and Senior Manager, as well as on the Board of Directors, I have led numerous teams to create a new employees experience with Workday

Comments and Discussions