BizTalk强制在不使用xslt调用模板的情况下创建空元素 [英] BizTalk force empty elements to be created without using xslt call template
问题描述
在不使用xslt调用模板的情况下,当源元素不存在时,BizTalk映射中是否仍然存在要强制创建目标元素的问题?
我正在将父/子xml映射到wcf-sql适配器生成的架构,该架构具有用于存储的proc参数的表值参数.
所以我的源xml是:
<Category>
<CategoryId>1</CategoryId>
<CategoryName>Test</CategoryName>
</Category>
和/或带有媒体的类别
<Category>
<CategoryId>1</CategoryId>
<CategoryName>Test</CategoryName>
<Media>
<Medium>
<MediumId>1</MediumId>
<MediumName>test.jpg</MediumName>
</Medium>
</Media>
</Category>
TypedProcedure的架构类似于:
<ImportCategoryRequest>
<Category>
<CategoryId>1</CategoryId>
<CategoryName>Test</CategoryName>
</Category>
<Media>
<Medium>
<MediumId>1</MediumId>
<MediumName>test.jpg</MediumName>
</Medium>
</Media>
</ImportCategoryRequest>
所以当目标XML中全部显示出来时,它不喜欢它.而不是为表值参数传递null,它至少需要1行,并为tvp中的列传递null值.我可以使用xslt调用模板创建虚拟xml,但我想避免这种情况.
BizTalk映射器似乎使用<xsl:for-each>
,如果没有输入,结果将不会生成输出元素.
但是使用xslt确实很容易-请参见 Is there anyway in a BizTalk map to force destination elements to be created when the source elements don't exist without using an xslt call template? I'm mapping parent/child xml to a wcf-sql adapter generated schema that has table-valued parameters for stored proc parameters. So my source xml is: and/or a Category with Media The schema for the TypedProcedure is something like: So it doesn't like it when is all that shows up in the destination XML. Instead of passing null for a table-valued parameter it wants at least 1 row and to pass null values for the columns in the tvp. I can create the dummy xml with a xslt call-template but I'd like to avoid that. The BizTalk mapper seems to use But using xslt is really easy - see here how to scrape the xslt out of your existing map (and just remove the escaping around double quotes and slashes), and to change the map to custom XSLT. The bit you need to change is around the Media is something like:
这篇关于BizTalk强制在不使用xslt调用模板的情况下创建空元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!<Category>
<CategoryId>1</CategoryId>
<CategoryName>Test</CategoryName>
</Category>
<Category>
<CategoryId>1</CategoryId>
<CategoryName>Test</CategoryName>
<Media>
<Medium>
<MediumId>1</MediumId>
<MediumName>test.jpg</MediumName>
</Medium>
</Media>
</Category>
<ImportCategoryRequest>
<Category>
<CategoryId>1</CategoryId>
<CategoryName>Test</CategoryName>
</Category>
<Media>
<Medium>
<MediumId>1</MediumId>
<MediumName>test.jpg</MediumName>
</Medium>
</Media>
</ImportCategoryRequest>
<xsl:for-each>
and as a result won't generate an output element if there is no input. <xsl:choose>
<xsl:when test="count(ns0:Media)!=0">
<!-- Copy the mapper generated XSLT in the for each here-->
<xsl:foreach >
</xsl:for-each>
</xsl:when>
<xsl:otherwise>
<Media>
<Medium>
<MediumId>1</MediumId>
<MediumName>test.jpg</MediumName>
</Medium>
</Media>
</xsl:otherwise>
</xsl:choose>