Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/google-chrome/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Xml 将非分层数据映射到分层数据_Xml_Map_Mapping_Biztalk - Fatal编程技术网

Xml 将非分层数据映射到分层数据

Xml 将非分层数据映射到分层数据,xml,map,mapping,biztalk,Xml,Map,Mapping,Biztalk,假设我有以下需要映射的xml文件 来源 <Persons> <Person> <Id>2</Id> <ParentId>3</ParentId> <Name>Some dude</Name> </Person> <Person> <Id>3</Id>

假设我有以下需要映射的xml文件

来源

<Persons>
    <Person>
        <Id>2</Id>
        <ParentId>3</ParentId>
        <Name>Some dude</Name>
    </Person>
    <Person>
        <Id>3</Id>
        <ParentId></ParentId>
        <Name>Some dude2</Name>
    </Person>
</Persons>

2.
3.
某个家伙
3.
一些家伙2
目的地

<Persons>
    <Person>
        <Name>Some dude</Name>
        <Parent>
            <Name>Some dude2</Name>
        </Parent>
    </Person>
</Persons>

某个家伙
一些家伙2
现在,我应该如何将正确的父对象对应到biztalk映射中的人员


如果您将BizTalk BTM映射更改为使用而不是visual spiderweb,然后应用以下xslt(显然BizTalk通常也需要名称空间),请多谢

<?xml version="1.0" encoding="UTF-8"?>
<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[normalize-space(ParentId/text()) != '']" />
        </Persons>
    </xsl:template>

    <xsl:template match="Person">
        <Person>
            <Name>
                <xsl:value-of select="Name/text()"/>
            </Name>
            <Parent>
                <Name>
                    <xsl:variable name="parentId" select="ParentId/text()" />
                    <xsl:value-of select="/Persons/Person[Id=$parentId]/Name/text()" />
                </Name>
            </Parent>
        </Person>
    </xsl:template>
</xsl:stylesheet>
<xsl:apply-templates select="Person" />