我正在尝试为XML数据实现XSLT映射。
这是我正在寻找的。 p>
输入XML:
<ListOfPersons xmlns="http://ws.wso2.org/dataservice">
<PersonDisclosureDate>
<Emplid>123456</Emplid>
<uniqname>abcd</uniqname>
<HasDisclosed>0</HasDisclosed>
<HasDisclosedThisFY>1</HasDisclosedThisFY>
<LastDiscloseDt></LastDiscloseDt>
<HasInterest>1</HasInterest>
<oeID>FI00006088</oeID>
<oeName>ArborSense, Inc.</oeName>
<oeStatus>Under Modification</oeStatus>
<oeSignDate>2016-07-15T15:53:42.000-04:00</oeSignDate>
<relationship>ID00000001</relationship>
<Types>Equity Interest - Non-Public::Advisory, Strategic, Scientific, or Medical Board; and/or Government Agency::Leadership Role</Types>
<startdt>2016-02-08T00:00:00.000-05:00</startdt>
<enddt/>
<oeDCstate>Department Review</oeDCstate>
</PersonDisclosureDate>
<PersonDisclosureDate>
<Emplid>23456</Emplid>
<uniqname>pqr</uniqname>
<HasDisclosed>0</HasDisclosed>
<HasDisclosedThisFY>1</HasDisclosedThisFY>
<LastDiscloseDt></LastDiscloseDt>
<HasInterest>1</HasInterest>
<oeID>FI00003483</oeID>
<oeName>Dimension Therapeutics</oeName>
<oeStatus>Under Modification</oeStatus>
<oeSignDate>2016-09-30T09:09:05.000-04:00</oeSignDate>
<relationship>ID00000001</relationship>
<Types>Consultant</Types>
<startdt>2014-11-18T00:00:00.000-05:00</startdt>
<enddt/>
<oeDCstate>Department Review</oeDCstate>
</PersonDisclosureDate>
<PersonDisclosureDate>
<Emplid>23456</Emplid>
<uniqname>pqr</uniqname>
<HasDisclosed>0</HasDisclosed>
<HasDisclosedThisFY>1</HasDisclosedThisFY>
<LastDiscloseDt></LastDiscloseDt>
<HasInterest>1</HasInterest>
<oeID>FI00007824</oeID>
<oeName>intercept</oeName>
<oeStatus>Under Modification</oeStatus>
<oeSignDate>2016-09-30T09:09:58.000-04:00</oeSignDate>
<relationship>ID00000001</relationship>
<Types>Advisory, Strategic, Scientific, or Medical Board; and/or Government Agency::Travel</Types>
<startdt>2016-10-05T00:00:00.000-04:00</startdt>
<enddt/>
<oeDCstate>Department Review</oeDCstate>
</PersonDisclosureDate>
<PersonDisclosureDate>
<Emplid>23456</Emplid>
<uniqname>pqr</uniqname>
<HasDisclosed>0</HasDisclosed>
<HasDisclosedThisFY>1</HasDisclosedThisFY>
<LastDiscloseDt></LastDiscloseDt>
<HasInterest>1</HasInterest>
<oeID>FI00007823</oeID>
<oeName>wilson therapeutics</oeName>
<oeStatus>Under Modification</oeStatus>
<oeSignDate>2016-09-30T09:09:31.000-04:00</oeSignDate>
<relationship>ID00000001</relationship>
<Types>Advisory, Strategic, Scientific, or Medical Board; and/or Government Agency::Travel</Types>
<startdt>2016-11-09T00:00:00.000-05:00</startdt>
<enddt/>
<oeDCstate>Department Review</oeDCstate>
</PersonDisclosureDate>
<PersonDisclosureDate>
<Emplid>34567</Emplid>
<uniqname>xyz</uniqname>
<HasDisclosed xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/>
<HasDisclosedThisFY>0</HasDisclosedThisFY>
<LastDiscloseDt xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/>
<HasInterest xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/>
<oeID xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/>
<oeName xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/>
<oeStatus xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/>
<oeSignDate xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/>
<relationship xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/>
<Types xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/>
<startdt xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/>
<enddt/>
<oeDCstate/>
</PersonDisclosureDate>
</ListOfPersons>
预期回复:
<?xml version="1.0" encoding="UTF-8"?>
<DisclosureData xsi:noNamespaceSchemaLocation="C:/XSL/eResearch_Expected_Response.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<count>3</count>
<disclosures>
<uniqName>abcd</uniqName>
<hasDisclosed>0</hasDisclosed>
<lastDiscloseDt></lastDiscloseDt>
<disclosureRecords>
<oeId>FI00006088</oeId>
<oeName>ArborSense, Inc.</oeName>
<oeSignDate>2016-07-15T15:53:42.000-04:00</oeSignDate>
<oeRelationship>ID00000001</oeRelationship>
<oeTypes>Equity Interest - Non-Public::Advisory, Strategic, Scientific, or Medical Board; and/or Government Agency::Leadership Role</oeTypes>
<oeStartDt>2016-02-08T00:00:00.000-05:00</oeStartDt>
<oeEndDt/>
</disclosureRecords>
</disclosures>
<disclosures>
<uniqName>pqr</uniqName>
<hasDisclosed>0</hasDisclosed>
<lastDiscloseDt></lastDiscloseDt>
<disclosureRecords>
<oeId>FI00003483</oeId>
<oeName>Dimension Therapeutics</oeName>
<oeSignDate>2016-09-30T09:09:05.000-04:00</oeSignDate>
<oeRelationship>ID00000001</oeRelationship>
<oeTypes>Consultant</oeTypes>
<oeStartDt>2014-11-18T00:00:00.000-05:00</oeStartDt>
<oeEndDt/>
</disclosureRecords>
<disclosureRecords>
<oeId>FI00007824</oeId>
<oeName>intercept</oeName>
<oeSignDate>2016-09-30T09:09:58.000-04:00</oeSignDate>
<oeRelationship>ID00000001</oeRelationship>
<oeTypes>Advisory, Strategic, Scientific, or Medical Board; and/or Government Agency::Travel</oeTypes>
<oeStartDt>2016-10-05T00:00:00.000-04:00</oeStartDt>
<oeEndDt/>
</disclosureRecords>
<disclosureRecords>
<oeId>FI00007823</oeId>
<oeName>wilson therapeutics</oeName>
<oeSignDate>2016-09-30T09:09:31.000-04:00</oeSignDate>
<oeRelationship>ID00000001</oeRelationship>
<oeTypes>Advisory, Strategic, Scientific, or Medical Board; and/or Government Agency::Travel</oeTypes>
<oeStartDt>2016-11-09T00:00:00.000-05:00</oeStartDt>
<oeEndDt/>
</disclosureRecords>
</disclosures>
<disclosures>
<uniqName>xyz</uniqName>
<hasDisclosed/>
<lastDiscloseDt/>
<disclosureRecords>
<oeId/>
<oeName/>
<oeSignDate/>
<oeRelationship/>
<oeTypes/>
<oeStartDt/>
<oeEndDt/>
</disclosureRecords>
</disclosures>
</DisclosureData>
我尝试使用ALtova Mapforce工具映射xml,但没有得到正确的结果。
有人可以使用Altova Mapforce甚至是使用group by标签的普通XSLT文档提供有关如何实现上述结果的一些指导吗?
提前致谢, Kranthi
答案 0 :(得分:1)
似乎是一个简单的for-each-groups选择PersonDisclosureDate
并按uniqname
进行分组。
这是一个使用拉方法的简单基本示例......
XSLT 2.0 (此处的工作示例:http://xsltfiddle.liberty-development.net/nbUY4kp)
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xpath-default-namespace="http://ws.wso2.org/dataservice">
<xsl:output indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:template match="/*">
<DisclosureData xsi:noNamespaceSchemaLocation="C:/XSL/eResearch_Expected_Response.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<count><xsl:value-of select="count(distinct-values(/*/PersonDisclosureDate/uniqname))"/></count>
<xsl:for-each-group select="PersonDisclosureDate" group-by="uniqname">
<disclosures>
<uniqName><xsl:value-of select="current-grouping-key()"/></uniqName>
<hasDisclosed><xsl:value-of select="current-group()[1]/HasDisclosed"/></hasDisclosed>
<lastDiscloseDt><xsl:value-of select="current-group()[1]/LastDiscloseDt"/></lastDiscloseDt>
<xsl:for-each select="current-group()">
<disclosureRecords>
<oeId><xsl:value-of select="oeID"/></oeId>
<oeName><xsl:value-of select="oeName"/></oeName>
<oeSignDate><xsl:value-of select="oeSignDate"/></oeSignDate>
<oeRelationship><xsl:value-of select="relationship"/></oeRelationship>
<oeTypes><xsl:value-of select="Types"/></oeTypes>
<oeStartDt><xsl:value-of select="startdt"/></oeStartDt>
<oeEndDt><xsl:value-of select="enddt"/></oeEndDt>
</disclosureRecords>
</xsl:for-each>
</disclosures>
</xsl:for-each-group>
</DisclosureData>
</xsl:template>
</xsl:stylesheet>