2

I'm trying to split an incoming message in the following form:

 <Items>
    <BatchID>123</BatchID>
    <Item>...</Item>
    <Item>...</Item>
    <Item>...</Item>
  </Items>

I've a pipeline with a XML disassembler which takes the Items schema and outputs the Item schema. On the Items schema, the Envelope property is set to true, and the "Body XPath" property points to the Items element.

However, when I try to process a file, I get the error: Finding the document specification by message type "BatchID" failed. Verify the schema deployed properly., presumably because it's expect only Item elements, and it doesn't know what to do with the BatchID element.

If I make the BatchID an attribute on the Items element (like a sensible person would have), everything works fine. Unfortunately, I'm stuck with the layout.

At this time, I do not care what is the value of BatchID.

How do I get it to split the message?

James Curran
  • 101,701
  • 37
  • 181
  • 258

1 Answers1

2

AFAIK the Xml disassembler always extracts all child nodes of the specified body_xpath element - it would have been a nice feature to be able to specify Item Xpath instead :(.

You can workaround this limitation by either:

  • Creating a schema for the undesirable <BatchID> element, and then just eat instances of it, e.g. creating a subscribing send port using TomasR's Null Adapter
  • or, Transform the envelope in a map on the receive port, before the envelope is debatched, where the transform strips out the unwanted Batch element

The following XSLT should do the trick:

<?xml version="1.0" encoding="utf-8"?>
<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" version="1.0" xmlns:ns0="http://BizTalk_Server_Project3.Envelope">
    <xsl:output omit-xml-declaration="yes" method="xml" version="1.0" />
    <xsl:template match="/">
        <xsl:apply-templates select="/ns0:Items" />
    </xsl:template>
    <xsl:template match="/ns0:Items">
        <ns0:Items>
            <!--i.e. Copy all Item elements and discard the Batch elements-->
            <xsl:copy-of select="ns0:Item"/>
        </ns0:Items>
    </xsl:template>
</xsl:stylesheet>

See here on how to convert a btm from a visual map to xslt

Community
  • 1
  • 1
StuartLC
  • 104,537
  • 17
  • 209
  • 285
  • I thought of doing your second bullet point myself after I posted the question. However, the debatching is done in a pipeline on the send port, and pipelines are done before maps on receive ports. – James Curran Nov 13 '12 at 23:47