当节点字段值存在时,XML排序

时间:2017-08-30 13:05:53

标签: xml xslt-grouping

请帮我解决以下问题 XML输入:

<EmploymentUpdateRequest>
  <CompanyNo>0070</CompanyNo>
  <EmploymentNo>982116</EmploymentNo>
  <Fields>
    <FieldValue Name="EmpFrom" Type="Date">
      <ValidFrom Format="yyyy-MM-dd">2017-04-14</ValidFrom>
      <ValidUntil Format="yyyy-MM-dd">2099-12-31</ValidUntil>
      <Value Format="yyyy-MM-dd">2017-04-14</Value>
    </FieldValue>
  </Fields>
</EmploymentUpdateRequest>
<EmploymentUpdateRequest>
  <CompanyNo>0070</CompanyNo>
  <EmploymentNo>982116</EmploymentNo>
  <Fields>
    <FieldValue Name="EmpFrom" Type="Date">
      <ValidFrom Format="yyyy-MM-dd">2017-01-14</ValidFrom>
      <ValidUntil Format="yyyy-MM-dd">2017-04-13</ValidUntil>
      <Value Format="yyyy-MM-dd">2017-01-14</Value>
    </FieldValue>
    <FieldValue Name="FORNAMN" Type="String">
      <ValidFrom Format="yyyy-MM-dd">2017-01-14</ValidFrom>
      <ValidUntil Format="yyyy-MM-dd">2017-04-13</ValidUntil>
      <Value>Bianca</Value>
    </FieldValue>
</EmploymentUpdateRequest>
<EmploymentUpdateRequest>
  <CompanyNo>0070</CompanyNo>
  <EmploymentNo>982116</EmploymentNo>
  <Fields>
    <FieldValue Name="EmpFrom" Type="Date">
      <ValidFrom Format="yyyy-MM-dd">2017-01-14</ValidFrom>
      <ValidUntil Format="yyyy-MM-dd">2017-04-13</ValidUntil>
      <Value Format="yyyy-MM-dd">2017-01-14</Value>
    </FieldValue>
    <FieldValue Name="FORNAMN" Type="String">
      <ValidFrom Format="yyyy-MM-dd">2017-05-14</ValidFrom>
      <ValidUntil Format="yyyy-MM-dd">2017-06-13</ValidUntil>
      <Value>Bianca</Value>
    </FieldValue>
  </Fields>
</EmploymentUpdateRequest>
<EmploymentUpdateRequest>
  <CompanyNo>0070</CompanyNo>
  <EmploymentNo>982116</EmploymentNo>
  <Fields>
    <FieldValue Name="EmpFrom" Type="Date">
      <ValidFrom Format="yyyy-MM-dd">2017-01-14</ValidFrom>
      <ValidUntil Format="yyyy-MM-dd">2017-04-13</ValidUntil>
      <Value Format="yyyy-MM-dd">2017-01-14</Value>
    </FieldValue>
    <FieldValue Name="FORNAMN" Type="String">
      <ValidFrom Format="yyyy-MM-dd">2017-02-14</ValidFrom>
      <ValidUntil Format="yyyy-MM-dd">2017-03-13</ValidUntil>
      <Value>Bianca</Value>
    </FieldValue>
  </Fields>
</EmploymentUpdateRequest>
</EmploymentUpdateRequests>

这需要按所有相同的就业号,子节点FORNAMN / ValidFrom日期值按升序排序。当FORNAMN不为空时。如果它为null,则将所有这些节点移动到输出的底部,不进行排序。 预期产出:

<EmploymentUpdateRequest>
  <CompanyNo>0070</CompanyNo>
  <EmploymentNo>982116</EmploymentNo>
  <Fields>
    <FieldValue Name="EmpFrom" Type="Date">
      <ValidFrom Format="yyyy-MM-dd">2017-01-14</ValidFrom>
      <ValidUntil Format="yyyy-MM-dd">2017-04-13</ValidUntil>
      <Value Format="yyyy-MM-dd">2017-01-14</Value>
    </FieldValue>
    <FieldValue Name="FORNAMN" Type="String">
      <ValidFrom Format="yyyy-MM-dd">2017-01-14</ValidFrom>
      <ValidUntil Format="yyyy-MM-dd">2017-04-13</ValidUntil>
      <Value>Bianca</Value>
    </FieldValue>
</EmploymentUpdateRequest>
<EmploymentUpdateRequest>
  <CompanyNo>0070</CompanyNo>
  <EmploymentNo>982116</EmploymentNo>
  <Fields>
    <FieldValue Name="EmpFrom" Type="Date">
      <ValidFrom Format="yyyy-MM-dd">2017-01-14</ValidFrom>
      <ValidUntil Format="yyyy-MM-dd">2017-04-13</ValidUntil>
      <Value Format="yyyy-MM-dd">2017-01-14</Value>
    </FieldValue>
    <FieldValue Name="FORNAMN" Type="String">
      <ValidFrom Format="yyyy-MM-dd">2017-02-14</ValidFrom>
      <ValidUntil Format="yyyy-MM-dd">2017-03-13</ValidUntil>
      <Value>Bianca</Value>
    </FieldValue>
  </Fields>
</EmploymentUpdateRequest>
<EmploymentUpdateRequest>
  <CompanyNo>0070</CompanyNo>
  <EmploymentNo>982116</EmploymentNo>
  <Fields>
    <FieldValue Name="EmpFrom" Type="Date">
      <ValidFrom Format="yyyy-MM-dd">2017-01-14</ValidFrom>
      <ValidUntil Format="yyyy-MM-dd">2017-04-13</ValidUntil>
      <Value Format="yyyy-MM-dd">2017-01-14</Value>
    </FieldValue>
    <FieldValue Name="FORNAMN" Type="String">
      <ValidFrom Format="yyyy-MM-dd">2017-05-14</ValidFrom>
      <ValidUntil Format="yyyy-MM-dd">2017-06-13</ValidUntil>
      <Value>Bianca</Value>
    </FieldValue>
  </Fields>
</EmploymentUpdateRequest>
<EmploymentUpdateRequest>
  <CompanyNo>0070</CompanyNo>
  <EmploymentNo>982116</EmploymentNo>
  <Fields>
    <FieldValue Name="EmpFrom" Type="Date">
      <ValidFrom Format="yyyy-MM-dd">2017-04-14</ValidFrom>
      <ValidUntil Format="yyyy-MM-dd">2099-12-31</ValidUntil>
      <Value Format="yyyy-MM-dd">2017-04-14</Value>
    </FieldValue>
  </Fields>
</EmploymentUpdateRequest>
</EmploymentUpdateRequests>

0 个答案:

没有答案