Home Page › Forums › BizTalk 2004 – BizTalk 2010 › Mapping sequential xml records . . . › Re: Mapping sequential xml records . . .
You will need to use a custom Xslt.
Here is an example that works with the examples above:
<?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" xmlns:userCSharp="http://schemas.microsoft.com/BizTalk/2003/userCSharp" exclude-result-prefixes="msxsl var userCSharp" version="1.0">
<xsl:output indent = "yes" omit-xml-declaration="yes" method="xml" version="1.0" />
<xsl:template match="/">
<xsl:apply-templates select="/Root" />
</xsl:template>
<xsl:template match="/Root">
<Root>
<xsl:for-each select="Record">
<Record>
<xsl:if test="@attrib1">
<xsl:attribute name="attrib1">
<xsl:value-of select="@attrib1" />
</xsl:attribute>
</xsl:if>
<xsl:variable name="reset" select="userCSharp:Reset()"/>
<xsl:for-each select="following-sibling::*">
<xsl:if test="userCSharp:MapChild(local-name())">
<NoteToRecord>
<xsl:if test="@attrib1">
<xsl:attribute name="attrib1">
<xsl:value-of select="@attrib1" />
</xsl:attribute>
</xsl:if>
</NoteToRecord>
</xsl:if>
</xsl:for-each>
</Record>
</xsl:for-each>
</Root>
</xsl:template>
<msxsl:script language="C#" implements-prefix="userCSharp">
<![CDATA[
bool done = false;
public void Reset()
{
done = false;
}
public bool MapChild(string nodename)
{
if (nodename == "Record")
{
done = true;
}
return !done;
}
]]>
</msxsl:script>
</xsl:stylesheet>