0

有没有办法获取如下所示的 XML 文件:

<?xml version="1.0" encoding="utf-8"?>
<spMyStoredProc xmlns="http://schemas.microsoft.com/Sql/2008/05/TypedProcedures/dbo">
<StoredProcedureResultSet0>
     <StoredProcedureResultSet0 xmlns="http://schemas.microsoft.com/Sql/2008/05/TypedProcedures/dbo/spMyStoredProc">
       <Item>1</Item>
       <Property>something</property>
     </StoredProcedureResultSet0>
     <StoredProcedureResultSet0 xmlns="http://schemas.microsoft.com/Sql/2008/05/TypedProcedures/dbo/spMyStoredProc">
       <Item>2</Item>
       <Property>something</property>
     </StoredProcedureResultSet0>
     <StoredProcedureResultSet0 xmlns="http://schemas.microsoft.com/Sql/2008/05/TypedProcedures/dbo/spMyStoredProc">
       <Item>3</Item>
       <Property>something</property>
       <Group>1</Group>
     </StoredProcedureResultSet0>
     <StoredProcedureResultSet0 xmlns="http://schemas.microsoft.com/Sql/2008/05/TypedProcedures/dbo/spMyStoredProc">
       <Item>4</Item>
       <Property>something</property>
       <Group>1</Group>
     </StoredProcedureResultSet0>
     <StoredProcedureResultSet0 xmlns="http://schemas.microsoft.com/Sql/2008/05/TypedProcedures/dbo/spMyStoredProc">
       <Item>5</Item>
       <Property>something</property>
       <Group>2</Group>
     </StoredProcedureResultSet0>
     <StoredProcedureResultSet0 xmlns="http://schemas.microsoft.com/Sql/2008/05/TypedProcedures/dbo/spMyStoredProc">
       <Item>6</Item>
       <Property>something</property>
       <Group>2</Group>
     </StoredProcedureResultSet0>
  </StoredProcedureResultSet0>
  <ReturnValue>0</ReturnValue>
</spMyStoredProc>

以这种格式出来:

<MyRequests>
    <Request>
       <Item ID="1" Property="Something" />
    </Request>
    <Request>
       <Item ID="2" Property="Something" />
    </Request>
    <Request GroupID="1">
       <Item ID="3" Property="Something" />
       <Item ID="4" Property="Something" />
    </Request>
    <Request GroupID="2">
       <Item ID="5" Property="Something" />
       <Item ID="6" Property="Something" />
    </Request>
</MyRequests>

我只使用从源模式到目标的直接映射就很接近了,但它不会将具有相同组 ID 的项目组合在一起。

基本上,没有functoids我能得到的是:

<MyRequests>
    <Request>
       <Item ID="1" Property="Something" />
    </Request>
    <Request>
       <Item ID="2" Property="Something" />
    </Request>
    <Request GroupID="1">
       <Item ID="3" Property="Something" />
    </Request>
    <Request GroupID="1">
       <Item ID="4" Property="Something" />
    </Request>
    <Request GroupID="2">
       <Item ID="5" Property="Something" />
    </Request>
    <Request GroupID="2">
       <Item ID="6" Property="Something" />
    </Request>
</MyRequests>
4

1 回答 1

1

听起来Biztalk 不支持 XSLT 2.0,所以这个答案是关于 XSLT 1.0 的。

假设您的 XML 输入文件格式正确,即包装在单个顶级元素中......

这种分组问题的标准方法是 Meunchian 分组。参见例如https://stackoverflow.com/a/1929273/423105https://stackoverflow.com/a/2334224/423105。如果您在应用这些答案时遇到问题,请发表评论并提出具体问题。

于 2014-01-27T21:04:28.033 回答