usenussi
Goto Top

Adresse in xml Datei durch xsl Datei trennen mit substring

Ich versuche hier verzweifelt eine Adresse in einer Muster.xml Datei nach dem Leerzeichen zu trennen. In der test.xsl Datei versuche ich den Befehl substring-before(current(),' ')" einzusetzen ohne
Erfolg. Die Überprüfung in Altova ergibt nicht den gewünschten Erfolg.
Was mache ich falsch? In der Output XML sollte Name 2 Mustermann stehen und bei Name3 Max. Die Hausnummer würde ich auch gerne in ein zusätzliches Feld schreiben.
Vielen Dank im voraus.
Udo

 Muster.xml
<?xml version="1.0" encoding="UTF-8"?>  
<AmazonEnvelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="amzn-envelope.xsd">  
  <Header>
    <DocumentVersion>1.01</DocumentVersion>
      <MerchantIdentifier>A6XT4ZI42K2JU</MerchantIdentifier>
  </Header>
  <MessageType>OrderReport</MessageType>
<Message>
    <MessageID>1</MessageID>
    <OrderReport>
        <AmazonOrderID>304-5691498-0815</AmazonOrderID>
        <AmazonSessionID>304-5691498-0816</AmazonSessionID>
        <OrderDate>2017-10-02T14:28:14+00:00</OrderDate>
        <OrderPostedDate>2017-10-02T14:28:14+00:00</OrderPostedDate>
        <BillingData>
            <AlreadyPaid/>
            <BuyerEmailAddress>47112@marketplace.amazon.de</BuyerEmailAddress>
            <BuyerName>Max  Ummlnger</BuyerName>
            <BuyerPhoneNumber>072335531</BuyerPhoneNumber>
            <Address>
                <Name>Max Mustermann</Name>
                <AddressFieldOne>Bochumer Str. 50/1</AddressFieldOne>
                <City>Köln</City>
                <StateOrRegion>Baden-Württemberg</StateOrRegion>
                <PostalCode>51105</PostalCode>
                <CountryCode>DE</CountryCode>
                <PhoneNumber>072335531</PhoneNumber>
            </Address>
        </BillingData>
        <FulfillmentData>
            <FulfillmentMethod>Ship</FulfillmentMethod>
            <FulfillmentServiceLevel>Standard</FulfillmentServiceLevel>
            <ShipServiceName>Std DE Dom_6</ShipServiceName>
            <Address>
                <Name>Max Mustermann</Name>
                <AddressFieldOne>Bochumer Str. 50/1</AddressFieldOne>
                <City>Köln</City>
                <StateOrRegion>Baden-Württemberg</StateOrRegion>
                <PostalCode>51105</PostalCode>
                <CountryCode>DE</CountryCode>
                <PhoneNumber>072335531</PhoneNumber>
            </Address>
        </FulfillmentData>
        <IsBusinessOrder>false</IsBusinessOrder>
        <IsPrime>false</IsPrime>
        <Item>
            <AmazonOrderItemCode>36664585999827</AmazonOrderItemCode>
            <SKU>VP-8WFY-VM3</SKU>
            <Title>Truma Gasinhaltsmesser Level Check, silber, für Stahl- und Alu-Gasflaschen 200-350 mm</Title>
            <CustomizationInfo>
               <Type>Condition</Type>
               <Data>new</Data>
            </CustomizationInfo>
            <CustomizationInfo>
               <Type>DateListed</Type>
               <Data>2015-06-17T09:29:43+00:00</Data>
            </CustomizationInfo>
            <CustomizationInfo>
               <Type>MarketplaceID</Type>
               <Data>A1PA6795UKMFR9</Data>
            </CustomizationInfo>
            <CustomizationInfo>
               <Type>CompoundTitle</Type>
               <Data>Truma Gasinhaltsmesser Level Check, silber, für Stahl- und Alu-Gasflaschen 20...</Data>
            </CustomizationInfo>
            <CustomizationInfo>
               <Type>ListingID</Type>
               <Data>0617PQQXCFS</Data>
            </CustomizationInfo>
            <CustomizationInfo>
               <Type>ConditionType</Type>
               <Data>new</Data>
            </CustomizationInfo>
            <CustomizationInfo>
               <Type>points_granted</Type>
               <Data>0</Data>
            </CustomizationInfo>
            <Quantity>1</Quantity>
            <ProductTaxCode>PTC_PRODUCT_TAXABLE_A</ProductTaxCode>
            <ItemPrice>
               <Component>
                  <Type>Principal</Type>
                  <Amount currency="EUR">72.90</Amount>  
               </Component>
               <Component>
                  <Type>Shipping</Type>
                  <Amount currency="EUR">4.00</Amount>  
               </Component>
               <Component>
                  <Type>Tax</Type>
                  <Amount currency="EUR">0.00</Amount>  
               </Component>
               <Component>
                  <Type>ShippingTax</Type>
                  <Amount currency="EUR">0.00</Amount>  
               </Component>
               <Component>
                  <Type>CODFee</Type>
                  <Amount currency="EUR">0.00</Amount>  
               </Component>
               <Component>
                   <Type>VatExclusiveItemPrice</Type>
                   <Amount currency="EUR">72.90</Amount>  
               </Component>
               <Component>
                   <Type>VatExclusiveShippingPrice</Type>
                   <Amount currency="EUR">4.00</Amount>  
               </Component>
            </ItemPrice>
            <ItemFees>
               <Fee>
                  <Type>Commission</Type>
                  <Amount currency="EUR">-11.54</Amount>  
               </Fee>
            </ItemFees>
            <IsAmazonInvoiced>false</IsAmazonInvoiced>
         </Item>
    </OrderReport>
</Message>
</AmazonEnvelope>

Test.xsl
<?xml version="1.0" encoding="ISO-8859-1"?>  
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">  
  <xsl:output method="xml" version="1.0" encoding="ISO-8859-1" indent="yes"/>  
  <xsl:template match="/AmazonEnvelope">  
    <ORDER_LIST>
      <xsl:for-each select="Message">  
        <ORDER xmlns="http://www.opentrans.org/XMLSchema/1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.0" type="standard">  
          <ORDER_HEADER>
            <!--<CONTROL_INFO>
              <GENERATOR_INFO>Custom XSL</GENERATOR_INFO>
              <GENERATION_DATE>
                <xsl:value-of select="current-dateTime()"/>  
              </GENERATION_DATE>
            </CONTROL_INFO>-->
            <ORDER_INFO>
              <REMARK type="order">Anlieferung: Per Paketdienst</REMARK>  
              <REMARK type="shipping_fee">  
                <xsl:value-of select="OrderReport/Item/ItemPrice/Component[Type='Shipping']/Amount"/>  
              </REMARK>
              <Gebühr>
                <xsl:value-of select="OrderReport/Item/ItemFees/Fee[Type='Commission']/Amount"/>  
              </Gebühr>
              <REMARK type="order">  
                <xsl:value-of select="OrderReport/Item/ItemFees/Fee[Type='Commission']/Amount"/>  
              </REMARK>
              <ORDER_ID>
                <xsl:value-of select="OrderReport/AmazonOrderID"/>  
              </ORDER_ID>
              <ORDER_DATE>
                <xsl:value-of select="OrderReport/OrderDate"/>  
              </ORDER_DATE>
              <ORDER_PARTIES>
                <BUYER_PARTY>
                  <!--Lieferadresse BUYER_PARTY-->
                  <PARTY>
                    <ADDRESS>
                      <NAME>
                        <xsl:value-of select="OrderReport/BillingData/Address/Name"/>  
                      </NAME>
                      <!--Firma Lieferadresse BUYER_PARTY-->
                      <NAME2>
                        <xsl:value-of select="OrderReport/BillingData/Address/Name/substring-before(current(),' ')"/>  
                      </NAME2>
                      <NAME3>
                        <xsl:value-of select="OrderReport/BillingData/Address/Name/substring-after(current(),' ')"/>  
                      </NAME3>                    
                    </ADDRESS>
                  </PARTY>
                </BUYER_PARTY>
                <INVOICE_PARTY>
                </INVOICE_PARTY>
              </ORDER_PARTIES>
              <PRICE_CURRENCY>978</PRICE_CURRENCY>
            </ORDER_INFO>
          </ORDER_HEADER>
          <ORDER_ITEM_LIST>
            <xsl:for-each select="OrderReport/Item">  
              <ORDER_ITEM>
                <LINE_ITEM_ID>
                  <xsl:value-of select="position()-1"/>  
                </LINE_ITEM_ID>
                <ARTICLE_ID>
                  <SUPPLIER_AID>
                    <xsl:value-of select="SKU"/>  
                  </SUPPLIER_AID>
                  <DESCRIPTION_SHORT>
                    <xsl:value-of select="Title"/>  
                  </DESCRIPTION_SHORT>
                  <!--<DESCRIPTION_LONG><xsl:value-of select="Title" /></DESCRIPTION_LONG>-->  
                </ARTICLE_ID>
                <QUANTITY>
                  <xsl:value-of select="Quantity"/>  
                </QUANTITY>
                <!-- hier wird die Bestellmenge als Variable deklariert, damit anschließend der Einzelpreis berechnet werden kann -->
                <xsl:copy-of select="Quantity"/>  
                <ORDER_UNIT>1</ORDER_UNIT>
                <ARTICLE_PRICE type="gros_list">  
                  <!--<PRICE_AMOUNT><xsl:value-of select="ItemPrice/Component[Type='Principal']/Amount" /></PRICE_AMOUNT>-->  
                  <!-- Der Einzelpreis wird durch PRICE_AMOUNT div QUANTITY (Gesamtpreis durch Menge)berchnet , da Amazon kein Einzelpreis übergibt -->
                  <PRICE_AMOUNT>
                    <xsl:value-of select="ItemPrice/Component[Type='Principal']/Amount div Quantity"/>  
                  </PRICE_AMOUNT>
                  <PRICE_LINE_AMOUNT>
                    <xsl:value-of select="ItemPrice/Component[Type='Principal']/Amount div Quantity"/>  
                  </PRICE_LINE_AMOUNT>
                  <TAX>[TODO]</TAX>
                </ARTICLE_PRICE>
              </ORDER_ITEM>
            </xsl:for-each>
          </ORDER_ITEM_LIST>
          <ORDER_SUMMARY>
            <TOTAL_ITEM_NUM><TOTAL_ITEM_NUM><xsl:value-of select="count('OrderReport/Item')"/></TOTAL_ITEM_NUM> </TOTAL_ITEM_NUM>  
            <TOTAL_AMOUNT>
              <TOTAL_AMOUNT>
                <xsl:value-of select="sum(OrderReport/Item/ItemPrice/Component[Type='Principal']/Amount)"/>  
              </TOTAL_AMOUNT>
            </TOTAL_AMOUNT>
            <TOTAL_AMOUNT>
              <xsl:value-of select="sum(OrderReport/Item/ItemPrice/Component[Type='Principal']/Amount)"/>  
            </TOTAL_AMOUNT>
            <QUANTITY>
              <xsl:value-of select="/ORDER_LIST/ORDER/ORDER_ITEM_LIST/ORDER_ITEM/Quantity"/>  
            </QUANTITY>
          </ORDER_SUMMARY>
        </ORDER>
      </xsl:for-each>
    </ORDER_LIST>
  </xsl:template>
</xsl:stylesheet>

Altova xsl Output

<?xml version="1.0" encoding="ISO-8859-1"?>  
<ORDER_LIST>
	<ORDER xmlns="http://www.opentrans.org/XMLSchema/1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.0" type="standard">  
		<ORDER_HEADER>
			<ORDER_INFO>
				<REMARK type="order">Anlieferung: Per Paketdienst</REMARK>  
				<REMARK type="shipping_fee">4.00</REMARK>  
				<Gebühr>-11.54</Gebühr>
				<REMARK type="order">-11.54</REMARK>  
				<ORDER_ID>304-5691498-0815</ORDER_ID>
				<ORDER_DATE>2017-10-02T14:28:14+00:00</ORDER_DATE>
				<ORDER_PARTIES>
					<BUYER_PARTY>
						<PARTY>
							<ADDRESS>
								<NAME>Max Mustermann</NAME>
								<NAME2>
</NAME2>
								<NAME3>   1
    
        304-5691498-0815
        304-5691498-0816
        2017-10-02T14:28:14+00:00
        2017-10-02T14:28:14+00:00
        
            
            47112@marketplace.amazon.de
            Max  Ummlnger
            072335531
            
                Max Mustermann
                Bochumer Str. 50/1
                Köln
                Baden-Württemberg
                51105
                DE
                072335531
            
        
        
            Ship
            Standard
            Std DE Dom_6
            
                Max Mustermann
                Bochumer Str. 50/1
                Köln
                Baden-Württemberg
                51105
                DE
                072335531
            
        
        false
        false
        
            36664585999827
            VP-8WFY-VM3
            Truma Gasinhaltsmesser Level Check, silber, für Stahl- und Alu-Gasflaschen 200-350 mm
            
               Condition
               new
            
            
               DateListed
               2015-06-17T09:29:43+00:00
            
            
               MarketplaceID
               A1PA6795UKMFR9
            
            
               CompoundTitle
               Truma Gasinhaltsmesser Level Check, silber, für Stahl- und Alu-Gasflaschen 20...
            
            
               ListingID
               0617PQQXCFS
            
            
               ConditionType
               new
            
            
               points_granted
               0
            
            1
            PTC_PRODUCT_TAXABLE_A
            
               
                  Principal
                  72.90
               
               
                  Shipping
                  4.00
               
               
                  Tax
                  0.00
               
               
                  ShippingTax
                  0.00
               
               
                  CODFee
                  0.00
               
               
                   VatExclusiveItemPrice
                   72.90
               
               
                   VatExclusiveShippingPrice
                   4.00
               
            
            
               
                  Commission
                  -11.54
               
            
            false
         
    
</NAME3>
							</ADDRESS>
						</PARTY>
					</BUYER_PARTY>
					<INVOICE_PARTY/>
				</ORDER_PARTIES>
				<PRICE_CURRENCY>978</PRICE_CURRENCY>
			</ORDER_INFO>
		</ORDER_HEADER>
		<ORDER_ITEM_LIST>
			<ORDER_ITEM>
				<LINE_ITEM_ID>0</LINE_ITEM_ID>
				<ARTICLE_ID>
					<SUPPLIER_AID>VP-8WFY-VM3</SUPPLIER_AID>
					<DESCRIPTION_SHORT>Truma Gasinhaltsmesser Level Check, silber, für Stahl- und Alu-Gasflaschen 200-350 mm</DESCRIPTION_SHORT>
				</ARTICLE_ID>
				<QUANTITY>1</QUANTITY>
				<Quantity xmlns="">1</Quantity>  
				<ORDER_UNIT>1</ORDER_UNIT>
				<ARTICLE_PRICE type="gros_list">  
					<PRICE_AMOUNT>72.9</PRICE_AMOUNT>
					<PRICE_LINE_AMOUNT>72.9</PRICE_LINE_AMOUNT>
					<TAX>[TODO]</TAX>
				</ARTICLE_PRICE>
			</ORDER_ITEM>
		</ORDER_ITEM_LIST>
		<ORDER_SUMMARY>
			<TOTAL_ITEM_NUM>
				<TOTAL_ITEM_NUM>1</TOTAL_ITEM_NUM> </TOTAL_ITEM_NUM>
			<TOTAL_AMOUNT>
				<TOTAL_AMOUNT>72.9</TOTAL_AMOUNT>
			</TOTAL_AMOUNT>
			<TOTAL_AMOUNT>72.9</TOTAL_AMOUNT>
			<QUANTITY/>
		</ORDER_SUMMARY>
	</ORDER>
</ORDER_LIST>

Content-ID: 353624

Url: https://administrator.de/contentid/353624

Ausgedruckt am: 26.11.2024 um 05:11 Uhr

134464
Lösung 134464 04.11.2017 aktualisiert um 08:54:01 Uhr
Goto Top
<xsl:value-of select="substring-before(OrderReport/BillingData/Address/Name,' ')"/>   
Viel Spaß wünsche ich bei Namen wie Franz Josef Meier ....
usenussi
usenussi 04.11.2017 um 10:11:18 Uhr
Goto Top
Vielen Dank, nun komme ich mit ähnlichen Problemen klar.
Nochmals Danke.