Получить значение из строки, которая содержит несколько значений - PullRequest
0 голосов
/ 15 января 2020
   <?xml version="1.0" encoding="UTF-8"?>
  <Message messageClass="EntityResponse" sender="BUYER" receiver="SELLER">
      <Header messageType="orderResponse" entityType="PurchaseOrder" entityReference="Test" sendingParty="H1822" destinationParty="FAE_MI002" timestamp="20200113 112929" messageInternalRef="7c1b4c53-f86f-41a2-b579-cd04780a3175" networkOwner="Test"/>
      <Content>
          <Order ID="Test_002" orderType="ServiceContract" issueDate="20200107" statusCode="accepted" buyerParty="H1822" buyerPartyTSId="fe303e43-0691-4934-8a28-b5d1f723ee71" buyerPartyName="Test" buyerCountryCode="NL" buyerPartyCountry="NL" sellerParty="FAE_MI002" sellerPartyTSId="9abb074a-16e6-4c4c-9fda-ef4622cb151f" sellerPartyName="Test" sellercountryCode="NL" sellerPartyCountry="NL" monetaryTotal="600.0" legalMonetaryTotal="726.0" taxTotalAmount="126.0" pricingCurrency="EUR" note="header note" deliveryAddressName="Test" tsWorkflowProfile="Test">
              <DynamicAttribute Name="requestoremployeeid" Value="EmployeeID"/>
              <TaxCategories>
                  <TaxCategory type="VAT" rate="21.0" taxAmount="126.0" taxableAmount="600.0"/>
              </TaxCategories>
              <OrderLine lineID="0001" lineType="original" lineStatusCode="accepted" accountingCost="600.0" item="ItemID-001" description="Item Description" buyerNote="line note" requestedQuantity="12.0" unitCode="EA" orderableUnitFactorRate="2.0" requestedPriceAmount="21.0" priceUnitFactorRate="1.0" requestedDeliveryPeriod="20200130" confirmedQuantity="12.0" confirmedPriceAmount="25.0" confirmedDeliveryPeriod="20200130" accountingLineTaxRate="21.0" requireExpiryDateASNFlag="false" requireBatchNumberASNFlag="false" previousLineStatusCode="changed" persistedPreviousLineStatusCode="changed" lineAfterConfirmFlag="false" lineSplitFlag="N">
                  <DynamicAttribute Name="costcentercode" Value="0012"/>
                  <DynamicAttribute Name="generalledgercode" Value="40500"/>
              </OrderLine>
          </Order>
          <Contact name="User" email="" role="Requestor" profile="BUYER"/>
      </Content>
  </Message>

Это мой пример сообщения. Теперь мне нужно выбрать этот OrderId, в данном случае это Test_002, и отобразить его, как показано ниже:

    <?xml version="1.0" encoding="UTF-8"?>
<Data>
    <Object Type="Purchase" Action="UpdateOrSkip">
        <Property Name="Id" Value="Test_002"/>
    </Object>
</Data>

1 Ответ

0 голосов
/ 15 января 2020

После некоторого возни я нашел ответ:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl">
    <xsl:output method="xml" encoding="UTF-8"  indent="yes"/>
    <xsl:template match="*">
        <Data>
            <xsl:for-each select="*">
                <Object Type="Purchase" Action="UpdateOrSkip" >
                    <Property Name="Id" Value="{Order/@ID}" />
                </Object>
            </xsl:for-each> 
        </Data>
    </xsl:template>
</xsl:stylesheet>

В результате:

<?xml version="1.0" encoding="UTF-8"?>
<Data>
    <Object Type="Purchase" Action="UpdateOrSkip">
        <Property Name="Id" Value="Test_ultimo_002"/>
        <Property Name="Context" Value="EmployeeContext.Standard"/>
        <Property Name="Description" Value=""/>
    </Object>
</Data>

...