【问题标题】:Get value from line which contains multiple values从包含多个值的行中获取值
【发布时间】:2020-01-15 10:59:24
【问题描述】:
   <?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>

【问题讨论】:

    标签: xml xslt xslt-1.0


    【解决方案1】:

    经过一番折腾,我找到了答案:

    <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>
    
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-09-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-12-27
      相关资源
      最近更新 更多