<?xml version="1.0" encoding="utf-16" ?>
<
xs:schema
xmlns:b
="
http://schemas.microsoft.com/BizTalk/2003
"
xmlns
="
http://DefaultNamespace.SourceSchema
"
targetNamespace
="
http://DefaultNamespace.SourceSchema
"
xmlns:xs
="
http://www.w3.org/2001/XMLSchema
">
<
xs:element name
="
SourceRoot
">
<
xs:complexType
>
<
xs:sequence
>
<
xs:element
name="SourceElement" type="xs:string" />
</
xs:sequence
>
<
xs:attribute
name="SourceAttribute" type="xs:string" />
</
xs:complexType
>
</
xs:element
>
</
xs:schema
>
|
<?xml version="1.0" encoding="utf-16" ?>
<
xs:schema
xmlns:b
="
http://schemas.microsoft.com/BizTalk/2003
"
xmlns
="
http://DefaultNamespace.TargetSchema
"
targetNamespace
="
http://DefaultNamespace.TargetSchema
"
xmlns:xs
="
http://www.w3.org/2001/XMLSchema
">
<
xs:element name
="
TargetRoot
">
<
xs:complexType
>
<
xs:sequence
>
<
xs:attribute
name="TargetAttribute" type="xs:string" />
</
xs:sequence
>
<
xs:attribute
name="TargetAttribute" type="xs:string" />
</
xs:complexType
>
</
xs:element
>
</
xs:schema
>
|
<ns0:SourceRoot SourceAttribute="SourceAttribute_0" xmlns:ns0="http://DefaultNamespace.SourceSchema">
<SourceElement>SourceElement_0</SourceElement>
</ns0:SourceRoot>
|
<?xml version="1.0" encoding="utf-8" ?>
<ns0:TargetRoot TargetAttribute="SourceAttribute_0" xmlns:ns0="http://DefaultNamespace.TargetSchema">
<TargetElement>SourceElement_0</TargetElement>
</ns0:TargetRoot>
|
<?xml version="1.0" encoding="utf-8" ?>
<TargetRoot TargetAttribute="SourceAttribute_0" xmlns="http://DefaultNamespace.TargetSchema">
<TargetElement>SourceElement_0</TargetElement>
</TargetRoot>
|
<?xml version="1.0" encoding="utf-8" ?>
<TargetRoot TargetAttribute="SourceAttribute_0">
<TargetElement>SourceElement_0</TargetElement>
</TargetRoot>
|
<?xml version="1.0" encoding="utf-8" ?>
<NewRootName TargetAttribute="SourceAttribute_0" xmlns="http://DefaultNamespace.NewTargetSchema">
<TargetElement>SourceElement_0</TargetElement>
</NewRootName>
|
Variable_String = Message_In.OuterXml;
Variable_String = Variable_String.Replace("<ns0:","<");
Variable_String = Variable_String.Replace("xmlns:ns0=","xmlns=");
Variable_String = Variable_String.Replace("</ns0:","</");
Variable_XmlDoc.LoadXml(Variable_String);
Message_Out = Variable_XmlDoc;
|
Variable_XmlDoc = Message_In;
Message_Out = SomeNamespace.Class.Method(Variable_XmlDoc);
|
using Microsoft.BizTalk.Component.Interop;
using Microsoft.BizTalk.Message.Interop;
|
public class DefaultNamespaceConvert :
//Microsoft.BizTalk.Component.BaseCustomTypeDescriptor,
Microsoft.BizTalk.Component.Interop.IBaseComponent,
Microsoft.BizTalk.Component.Interop.IComponent,
Microsoft.BizTalk.Component.Interop.IPersistPropertyBag,
Microsoft.BizTalk.Component.Interop.IComponentUI
|
public IBaseMessage Execute(IPipelineContext pContext, IBaseMessage pInMsg);
|
public IBaseMessage Execute(IPipelineContext pContext, IBaseMessage pInMsg)
{
IBaseMessagePart bodyPart = pInMsg.BodyPart;
if (bodyPart != null)
{
Stream originalStream = bodyPart.GetOriginalDataStream();
if (originalStream != null)
{
try
{
Stream outputStream = Convert(originalStream);
outputStream.Seek(0, SeekOrigin.Begin);
bodyPart.Data = outputStream;
pContext.ResourceTracker.AddResource(outputStream);
}
catch(Exception ex)
{
throw new Exception("Convert Error," + ex.Message);
}
}
}
return pInMsg;
}
|
<?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 s0
"
version
="
1.0
"
xmlns
="
http://DefaultNamespace.TargetSchema
"
xmlns:s0
="
http://DefaultNamespace.SourceSchema
">
<
xsl:output omit-xml-declaration="
no
" method="
xml
" version="
1.0
"
/>
<
xsl:template match
="
/
">
<
xsl:apply-templates
select="/s0:SourceRoot" />
</
xsl:template
>
<
xsl:template match
="
/s0:SourceRoot
">
<
TargetRoot
>
<
xsl:if test
="
@SourceAttribute
">
<
xsl:attribute name
="
TargetAttribute
">
<
xsl:value-of
select="@SourceAttribute" />
</
xsl:attribute
>
</
xsl:if
>
<
TargetElement
>
<
xsl:value-of
select="SourceElement/text()" />
</
TargetElement
>
</
TargetRoot
>
</
xsl:template
>
</
xsl:stylesheet
>
|