2011-05-05 38 views
0

我輸入的是一樣的東西:映射到集合的結構在BizTalk 2009年

<Person> 
<FirstName>abc</FirstName> 
<Bsn>2345467</Bsn> 
<Person> 

輸出應該是:

<Person> 
    <properties> 
    <property> 
     <propertyname> Firstname </propertyname> 
     <propertyValue> abc </propertyValue> 
    </property> 
    <property> 
     <propertyname> Bsn</propertyname> 
     <propertyValue> 2345467 </propertyValue> 
    </property> 
    </properties> 
</Person> 

我的意思是目標不具有特定屬性/ atrributes。相反,它有一個屬性集合,其中我指定屬性的名稱和屬性的值。

任何幫助,高度讚賞。

我使用BizTalk 2009年

請幫

+0

我都試過了,循環和表functiod,但沒有幫助。 ! – 2011-05-06 06:26:50

回答

1

我會使用自定義的XSLT在這種情況下─無論是通過使用scripting functiod或用自定義的XSLT文件替換整個地圖(取決於如何休息你的地圖看起來)。

該解決方案可能看起來像這樣。

XML

<Persons> 
<Person> 
    <FirstName>abc</FirstName> 
    <Bsn>2345467</Bsn> 
</Person> 
</Persons> 

XSLT

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> 
<xsl:output method="xml" indent="yes"/> 

<xsl:template match="Persons"> 
    <Persons> 
    <xsl:apply-templates select="Person" /> 
    </Persons> 
</xsl:template> 

<xsl:template match="Person"> 
    <Person> 
    <properties> 
    <xsl:apply-templates select="*" mode="properties" /> 
    </properties> 
    </Person> 
</xsl:template> 

<xsl:template match="node()" mode="properties"> 
    <property> 
    <propertyname> 
    <xsl:value-of select="local-name()"/> 
    </propertyname> 
    <propertyvalue> 
    <xsl:value-of select="."/> 
    </propertyvalue> 
</property> 
</xsl:template> 

</xsl:stylesheet> 

結果

<?xml version="1.0" encoding="utf-8"?> 
<Persons> 
    <Person> 
    <properties> 
    <property> 
    <propertyname>FirstName</propertyname> 
    <propertyvalue>abc</propertyvalue> 
    </property> 
    <property> 
    <propertyname>Bsn</propertyname> 
    <propertyvalue>2345467</propertyvalue> 
    </property> 
    </properties> 
    </Person> 
</Persons> 
+0

嗨Riri, 感謝您的迴應!我可以用** Table循環functoid **解決上述問題。但是,當我有一個更棘手的目標模式時,出現了一個轉折點。 現在的目標是這樣的: [1]:http://i.imgur.com/8r5ec.png 指本BSN被映射到擴展屬性的整數類型,而姓String類型的擴展屬性。 我無法達到此目的! 任何想法? – 2011-05-09 07:47:12