Xslt mit Bedingung anpassen, da Felder überschrieben werden
Hallo Experten, ich brauche eure Hilfe.
Ich bekomme meine xlm zur Weiterbearbeitung. Meine xslt funktioniert soweit ganz gut wenn eine Privatbestellung kommt. Problem bei Firmenadresse wird Street mit Firma überschrieben. Ich brauche eine Bedingung wenn <AddressFieldTwo> vorhanden ist.
Ich bekomme meine xlm zur Weiterbearbeitung. Meine xslt funktioniert soweit ganz gut wenn eine Privatbestellung kommt. Problem bei Firmenadresse wird Street mit Firma überschrieben. Ich brauche eine Bedingung wenn <AddressFieldTwo> vorhanden ist.
`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>A6XYZWI42K2JU</MerchantIdentifier>
</Header>
<MessageType>OrderReport</MessageType>
<Message>
<MessageID>1</MessageID>
<OrderReport>
<AmazonOrderID>028-4711789-5323504</AmazonOrderID>
<BillingData>
<AlreadyPaid/>
<BuyerEmailAddress>xpl0prxgdsxpyzg@marketplace.amazon.de</BuyerEmailAddress>
<BuyerName>Andrea Mustermann</BuyerName>
<BuyerPhoneNumber>05175/771578</BuyerPhoneNumber>
<Address>
<Name>Udo Mustermann</Name>
<AddressFieldOne>Bula Verpackungen GmbH</AddressFieldOne>
<AddressFieldTwo>Zum Bauhaus 1 a</AddressFieldTwo>
<City>Poll</City>
<StateOrRegion>NRW</StateOrRegion>
<PostalCode>51105</PostalCode>
<CountryCode>DE</CountryCode>
</Address>
</BillingData>
<FulfillmentData>
<Address>
<Name>Andrea Mustermann</Name>
<AddressFieldOne>Zum Bauhaus 1a</AddressFieldOne>
<City>Poll</City>
<StateOrRegion>NRW</StateOrRegion>
<PostalCode>51105</PostalCode>
<CountryCode>DE</CountryCode>
</Address>
</FulfillmentData>
<IsBusinessOrder>false</IsBusinessOrder>
<IsPrime>false</IsPrime>
<Item>
</Item>
</OrderReport>
</Message>
</AmazonEnvelope>
`Xslt`
<?xml version="1.0" encoding="UTF-8"?>
<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>
</CONTROL_INFO>
<ORDER_INFO>
<REMARK type="order">Anlieferung: Per Paketdienst</REMARK>
<REMARK type="shipping_fee">
<xsl:value-of select="round((OrderReport/Item/ItemPrice/Component[Type='Shipping']/Amount div 1.19) * 100) div 100"/>
</REMARK>
<ORDER_ID>
</ORDER_ID>
<ORDER_DATE>
</ORDER_DATE>
<ORDER_PARTIES>
<BUYER_PARTY>
<!--Lieferadresse BUYER_PARTY-->
<PARTY>
<ADDRESS>
<NAME>
<xsl:value-of select="OrderReport/FulfillmentData/Address/Name"/>
</NAME>
<!--Firma Lieferadresse BUYER_PARTY-->
<NAME2>
<xsl:value-of select="substring-after(OrderReport/FulfillmentData/Address/Name,' ')"/>
</NAME2>
<NAME3>
<xsl:value-of select="substring-before(OrderReport/FulfillmentData/Address/Name,' ')"/>
</NAME3>
<!--Nachname Lieferadresse BUYER_PARTY-->
<!--Vorname Lieferadresse BUYER_PARTY-->
<ANSCHRIFT_ZUSATZ>
<xsl:value-of select="OrderReport/FulfillmentData/Address/StateOrRegion"/>
</ANSCHRIFT_ZUSATZ>
<STREET>
<xsl:value-of select="OrderReport/FulfillmentData/Address/AddressFieldOne"/>
</STREET>
<Anschrift_HausNr>
<xsl:value-of select="substring-after(OrderReport/FulfillmentData/Address/AddressFieldOne, '. ')"/>
</Anschrift_HausNr>
<ZIP>
<xsl:value-of select="OrderReport/FulfillmentData/Address/PostalCode"/>
</ZIP>
<CITY>
<xsl:value-of select="OrderReport/FulfillmentData/Address/City"/>
</CITY>
<COUNTRY>
<xsl:value-of select="OrderReport/FulfillmentData/Address/CountryCode"/>
</COUNTRY>
<PHONE type="other">
<xsl:value-of select="OrderReport/FulfillmentData/Address/PhoneNumber"/>
</PHONE>
<FAX>
<!--<xsl:value-of select="OrderReport/FulfillmentData/Address/StateOrRegion"/>-->
</FAX>
<EMAIL>
</EMAIL>
</ADDRESS>
</PARTY>
</BUYER_PARTY>
<INVOICE_PARTY>
<!--Rechnungsadresse INVOICE_PARTY-->
<PARTY>
<ADDRESS>
<NAME>
<xsl:value-of select="OrderReport/BillingData/Address/AddressTwo"/>
</NAME>
<!--Firma in Lexware Rechnungsadresse INVOICE_PARTY-->
<!--Zuname in Lexware Rechnungsadresse INVOICE_PARTY-->
<NAME2>
<xsl:value-of select="substring-after(OrderReport/BillingData/Address/Name,' ')"/>
</NAME2>
<NAME3>
<xsl:value-of select="substring-before(OrderReport/BillingData/Address/Name,' ')"/>
</NAME3>
<!--Vorname in Lexware Rechnungsadresse INVOICE_PARTY-->
<ANSCHRIFT_ZUSATZ>
<xsl:value-of select="OrderReport/BillingData/Address/StateOrRegion"/>
</ANSCHRIFT_ZUSATZ>
<STREET>
<xsl:value-of select="OrderReport/BillingData/Address/AddressFieldOne"/>
</STREET>
<ZIP>
<xsl:value-of select="OrderReport/BillingData/Address/PostalCode"/>
</ZIP>
<CITY>
<xsl:value-of select="OrderReport/BillingData/Address/City"/>
</CITY>
<COUNTRY>
<xsl:value-of select="OrderReport/BillingData/Address/CountryCode"/>
</COUNTRY>
<ANSCHRIFT_ZUSATZ>
<xsl:value-of select="OrderReport/BillingData/Address/StateOrRegion"/>
</ANSCHRIFT_ZUSATZ>
<PHONE type="other">
<xsl:value-of select="OrderReport/BillingData/Address/PhoneNumber"/>
</PHONE>
<FAX/>
<EMAIL>
</EMAIL>
</ADDRESS>
</PARTY>
</INVOICE_PARTY>
</ORDER_PARTIES>
</ORDER_INFO>
</ORDER_HEADER>
<ORDER_ITEM_LIST>
</ORDER_ITEM_LIST>
<ORDER_SUMMARY>
</ORDER_SUMMARY>
</ORDER>
</xsl:for-each>
</ORDER_LIST>
</xsl:template>
</xsl:stylesheet>
`Ergebniss`
<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>
<CONTROL_INFO/>
<ORDER_INFO>
<REMARK type="order">Anlieferung: Per Paketdienst</REMARK>
<REMARK type="shipping_fee"/>
<ORDER_ID/>
<ORDER_DATE/>
<ORDER_PARTIES>
<BUYER_PARTY>
<PARTY>
<ADDRESS>
<NAME>Andrea Mustermann</NAME>
<NAME2>Mustermann</NAME2>
<NAME3>Andrea</NAME3>
<ANSCHRIFT_ZUSATZ>NRW</ANSCHRIFT_ZUSATZ>
<STREET>Zum Bauhaus 1a</STREET>
<Anschrift_HausNr/>
<ZIP>51105</ZIP>
<CITY>Poll</CITY>
<COUNTRY>DE</COUNTRY>
<PHONE type="other"/>
<FAX/>
<EMAIL/>
</ADDRESS>
</PARTY>
</BUYER_PARTY>
<INVOICE_PARTY>
<PARTY>
<ADDRESS>
<NAME/>
<NAME2>Mustermann</NAME2>
<NAME3>Udo</NAME3>
<ANSCHRIFT_ZUSATZ>NRW</ANSCHRIFT_ZUSATZ>
<STREET>Bula Verpackungen GmbH</STREET>
<ZIP>51105</ZIP>
<CITY>Poll</CITY>
<COUNTRY>DE</COUNTRY>
<ANSCHRIFT_ZUSATZ>NRW</ANSCHRIFT_ZUSATZ>
<PHONE type="other"/>
<FAX/>
<EMAIL/>
</ADDRESS>
</PARTY>
</INVOICE_PARTY>
</ORDER_PARTIES>
</ORDER_INFO>
</ORDER_HEADER>
<ORDER_ITEM_LIST/>
<ORDER_SUMMARY/>
</ORDER>
</ORDER_LIST>
Bitte markiere auch die Kommentare, die zur Lösung des Beitrags beigetragen haben
Content-ID: 366261
Url: https://administrator.de/contentid/366261
Ausgedruckt am: 22.11.2024 um 18:11 Uhr
2 Kommentare
Neuester Kommentar
Servus Udo.
Grüße Uwe
xsl:choose
ist dein Freund.<?xml version="1.0" encoding="UTF-8"?>
<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>
</CONTROL_INFO>
<ORDER_INFO>
<REMARK type="order">Anlieferung: Per Paketdienst</REMARK>
<REMARK type="shipping_fee">
<xsl:value-of select="round((OrderReport/Item/ItemPrice/Component[Type='Shipping']/Amount div 1.19) * 100) div 100"/>
</REMARK>
<ORDER_ID>
</ORDER_ID>
<ORDER_DATE>
</ORDER_DATE>
<ORDER_PARTIES>
<BUYER_PARTY>
<!--Lieferadresse BUYER_PARTY-->
<PARTY>
<ADDRESS>
<NAME>
<xsl:value-of select="OrderReport/FulfillmentData/Address/Name"/>
</NAME>
<!--Firma Lieferadresse BUYER_PARTY-->
<NAME2>
<xsl:value-of select="substring-after(OrderReport/FulfillmentData/Address/Name,' ')"/>
</NAME2>
<NAME3>
<xsl:value-of select="substring-before(OrderReport/FulfillmentData/Address/Name,' ')"/>
</NAME3>
<!--Nachname Lieferadresse BUYER_PARTY-->
<!--Vorname Lieferadresse BUYER_PARTY-->
<ANSCHRIFT_ZUSATZ>
<xsl:value-of select="OrderReport/FulfillmentData/Address/StateOrRegion"/>
</ANSCHRIFT_ZUSATZ>
<STREET>
<xsl:choose>
<xsl:when test="count(OrderReport/FulfillmentData/Address/AddressFieldTwo) > 0"><xsl:value-of select="OrderReport/FulfillmentData/Address/AddressFieldTwo"/></xsl:when>
<xsl:otherwise><xsl:value-of select="OrderReport/FulfillmentData/Address/AddressFieldOne"/></xsl:otherwise>
</xsl:choose>
</STREET>
<Anschrift_HausNr>
<xsl:value-of select="substring-after(OrderReport/FulfillmentData/Address/AddressFieldOne, '. ')"/>
</Anschrift_HausNr>
<ZIP>
<xsl:value-of select="OrderReport/FulfillmentData/Address/PostalCode"/>
</ZIP>
<CITY>
<xsl:value-of select="OrderReport/FulfillmentData/Address/City"/>
</CITY>
<COUNTRY>
<xsl:value-of select="OrderReport/FulfillmentData/Address/CountryCode"/>
</COUNTRY>
<PHONE type="other">
<xsl:value-of select="OrderReport/FulfillmentData/Address/PhoneNumber"/>
</PHONE>
<FAX>
<!--<xsl:value-of select="OrderReport/FulfillmentData/Address/StateOrRegion"/>-->
</FAX>
<EMAIL>
</EMAIL>
</ADDRESS>
</PARTY>
</BUYER_PARTY>
<INVOICE_PARTY>
<!--Rechnungsadresse INVOICE_PARTY-->
<PARTY>
<ADDRESS>
<NAME>
<xsl:value-of select="OrderReport/BillingData/Address/AddressTwo"/>
</NAME>
<!--Firma in Lexware Rechnungsadresse INVOICE_PARTY-->
<!--Zuname in Lexware Rechnungsadresse INVOICE_PARTY-->
<NAME2>
<xsl:value-of select="substring-after(OrderReport/BillingData/Address/Name,' ')"/>
</NAME2>
<NAME3>
<xsl:value-of select="substring-before(OrderReport/BillingData/Address/Name,' ')"/>
</NAME3>
<!--Vorname in Lexware Rechnungsadresse INVOICE_PARTY-->
<ANSCHRIFT_ZUSATZ>
<xsl:value-of select="OrderReport/BillingData/Address/StateOrRegion"/>
</ANSCHRIFT_ZUSATZ>
<STREET>
<xsl:choose>
<xsl:when test="count(OrderReport/BillingData/Address/AddressFieldTwo) > 0"><xsl:value-of select="OrderReport/BillingData/Address/AddressFieldTwo"/></xsl:when>
<xsl:otherwise><xsl:value-of select="OrderReport/BillingData/Address/AddressFieldOne"/></xsl:otherwise>
</xsl:choose>
</STREET>
<ZIP>
<xsl:value-of select="OrderReport/BillingData/Address/PostalCode"/>
</ZIP>
<CITY>
<xsl:value-of select="OrderReport/BillingData/Address/City"/>
</CITY>
<COUNTRY>
<xsl:value-of select="OrderReport/BillingData/Address/CountryCode"/>
</COUNTRY>
<ANSCHRIFT_ZUSATZ>
<xsl:value-of select="OrderReport/BillingData/Address/StateOrRegion"/>
</ANSCHRIFT_ZUSATZ>
<PHONE type="other">
<xsl:value-of select="OrderReport/BillingData/Address/PhoneNumber"/>
</PHONE>
<FAX/>
<EMAIL>
</EMAIL>
</ADDRESS>
</PARTY>
</INVOICE_PARTY>
</ORDER_PARTIES>
</ORDER_INFO>
</ORDER_HEADER>
<ORDER_ITEM_LIST>
</ORDER_ITEM_LIST>
<ORDER_SUMMARY>
</ORDER_SUMMARY>
</ORDER>
</xsl:for-each>
</ORDER_LIST>
</xsl:template>
</xsl:stylesheet>