juls_pro_37: XSLT - Knoteninhalt in einen weiteren Knoten kopieren

Hallo,

besteht die Möglichkeit mittels XSLT den Inhalt eines Knoten, in einem anderen bestehenden Knoten zu kopieren? - an einer bestimmten Position - also am Ende des Knotens?

Konkret geht es mir um folg. Tags, welche unter SEEDELFOR,...-> GRP und unter REF_ON angeführt werden sollen. -> Der Inhalt betrifft: ADD - mit dem Qualifier CN.

Diese Werte werden unter GRP - REF_ON benötigt, wenn der Qualifier CN vorhanden ist:

<PARTY_NAME_1>Vorname Nachname</PARTY_NAME_1>
<STREET_1>Teststraße</STREET_1>
<CITY>Test</CITY>
<POSTAL_CODE>12345</POSTAL_CODE>
<COUNTRY_CODE>DE</COUNTRY_CODE>

Originalfile:

<?xml version="1.0"?>
<SEEDELFOR>
	<SEE_AG COPYRIGHT="Name" CREATION_DATE="9999-99-99" MESSAGE="Message" MAPPING="Mapping" VERSION="1"/>
	<CNT>
		<TRANSMISSION_DATE></TRANSMISSION_DATE>
		<TRANSMISSION_TIME></TRANSMISSION_TIME>
		<INTERCHANGE_CONTROL_NUMBER></INTERCHANGE_CONTROL_NUMBER>
		<SENDER></SENDER>
		<SENDER_QUALIFIER></SENDER_QUALIFIER>
		<RECEIVER></RECEIVER>
		<RECEIVER_QUALIFIER></RECEIVER_QUALIFIER>
		<SYNTAX_IDENTIFIER></SYNTAX_IDENTIFIER>
		<SYNTAX_VERSION>3</SYNTAX_VERSION>
		<GRP>
			<IDENTIFIER_BY></IDENTIFIER_BY>
			<IDENTIFIER_MF></IDENTIFIER_MF>
			<IDENTIFIER_ST></IDENTIFIER_ST>
			<IDENTIFIER_SU></IDENTIFIER_SU>
			<IDENTIFIER_UD></IDENTIFIER_UD>
			<IDENTIFIER_CA></IDENTIFIER_CA>
			<DATE_4></DATE_4>
			<REF_ON></REF_ON>					
			<ADD>
				<QUALIFIER></QUALIFIER>
				<IDENTIFIER></IDENTIFIER>
				<AGENCY_CODE></AGENCY_CODE>
				<PARTY_NAME_1></PARTY_NAME_1>
				<STREET_1></STREET_1>
				<CITY></CITY>
				<POSTAL_CODE></POSTAL_CODE>
			</ADD>
			<ADD>
				<QUALIFIER></QUALIFIER>
				<IDENTIFIER></IDENTIFIER>
				<AGENCY_CODE></AGENCY_CODE>
				<PARTY_NAME_1></PARTY_NAME_1>
				<CITY></CITY>
				<POSTAL_CODE></POSTAL_CODE>
			</ADD>
			<ADD>
				<QUALIFIER></QUALIFIER>
				<IDENTIFIER></IDENTIFIER>
				<AGENCY_CODE></AGENCY_CODE>
				<PARTY_NAME_1></PARTY_NAME_1>
				<STREET_1></STREET_1>
				<CITY></CITY>
				<POSTAL_CODE></POSTAL_CODE>
			</ADD>
			<ADD>
				<QUALIFIER>CN</QUALIFIER>
				<IDENTIFIER></IDENTIFIER>
				<AGENCY_CODE></AGENCY_CODE>
				<PARTY_NAME_1>Vorname Nachname</PARTY_NAME_1>
				<STREET_1>Teststraße</STREET_1>
				<CITY>Test</CITY>
				<POSTAL_CODE>12345</POSTAL_CODE>
				<COUNTRY_CODE></COUNTRY_CODE>
				<CONTACT>
					<QUALIFIER></QUALIFIER>
					<NUMBER></NUMBER>
				</CONTACT>
			</ADD>
			<ADD>
				<QUALIFIER></QUALIFIER>
				<IDENTIFIER></IDENTIFIER>
				<AGENCY_CODE></AGENCY_CODE>
				<PARTY_NAME_1></PARTY_NAME_1>
				<STREET_1></STREET_1>
				<CITY></CITY>
				<POSTAL_CODE></POSTAL_CODE>
			</ADD>
			<ADD>
				<QUALIFIER></QUALIFIER>
				<IDENTIFIER></IDENTIFIER>
				<AGENCY_CODE></AGENCY_CODE>
				<PARTY_NAME_1></PARTY_NAME_1>
				<STREET_1></STREET_1>
				<CITY></CITY>
				<POSTAL_CODE></POSTAL_CODE>
				<CONTACT>
					<QUALIFIER></QUALIFIER>
					<NUMBER></NUMBER>
				</CONTACT>
			</ADD>
			<ADD>
				<QUALIFIER></QUALIFIER>
				<IDENTIFIER></IDENTIFIER>
				<AGENCY_CODE></AGENCY_CODE>
			</ADD>
			<TRANSPORT_DETAILS>
				<ADDITIONAL_DETAILS>
					<QUALIFIER></QUALIFIER>
					<DETAILS></DETAILS>
				</ADDITIONAL_DETAILS>
			</TRANSPORT_DETAILS>
			<ITEM>
				<ITEM_NUMBER_EN></ITEM_NUMBER_EN>
				<ITEM_NUMBER_IN></ITEM_NUMBER_IN>
				<ITEM_NUMBER_SA></ITEM_NUMBER_SA>
				<QUANTITY></QUANTITY>
				<QUANTITY_UNIT></QUANTITY_UNIT>
				<LINE_ITEM_NUMBER></LINE_ITEM_NUMBER>
				<AMOUNT_DETAILS>
					<QUALIFIER></QUALIFIER>
					<AMOUNT></AMOUNT>
					<CURRENCY></CURRENCY>
				</AMOUNT_DETAILS>
				<REF>
					<QUALIFIER></QUALIFIER>
					<REFERENCE></REFERENCE>
					<ADDITIONAL_INFO/>
				</REF>
				<REF>
					<QUALIFIER></QUALIFIER>
					<REFERENCE></REFERENCE>
					<ADDITIONAL_INFO/>
				</REF>
				<REF>
					<QUALIFIER></QUALIFIER>
					<REFERENCE></REFERENCE>
					<ADDITIONAL_INFO/>
				</REF>
				<PACKAGE_DETAILS>
					<NUMBER_OF_PACKAGES>1</NUMBER_OF_PACKAGES>
					<REF>
						<QUALIFIER></QUALIFIER>
						<REFERENCE></REFERENCE>
					</REF>
					<REF>
						<QUALIFIER></QUALIFIER>
						<REFERENCE></REFERENCE>
					</REF>
				</PACKAGE_DETAILS>
			</ITEM>
		</GRP>
	</CNT>
</SEEDELFOR>

Ergebnis sollte sein:

<?xml version="1.0"?>
<SEEDELFOR>
	<SEE_AG COPYRIGHT="Name" CREATION_DATE="9999-99-99" MESSAGE="Message" MAPPING="Mapping" VERSION="1"/>
	<CNT>
		<TRANSMISSION_DATE></TRANSMISSION_DATE>
		<TRANSMISSION_TIME></TRANSMISSION_TIME>
		<INTERCHANGE_CONTROL_NUMBER></INTERCHANGE_CONTROL_NUMBER>
		<SENDER></SENDER>
		<SENDER_QUALIFIER></SENDER_QUALIFIER>
		<RECEIVER></RECEIVER>
		<RECEIVER_QUALIFIER></RECEIVER_QUALIFIER>
		<SYNTAX_IDENTIFIER></SYNTAX_IDENTIFIER>
		<SYNTAX_VERSION>3</SYNTAX_VERSION>
		<GRP>
			<IDENTIFIER_BY></IDENTIFIER_BY>
			<IDENTIFIER_MF></IDENTIFIER_MF>
			<IDENTIFIER_ST></IDENTIFIER_ST>
			<IDENTIFIER_SU></IDENTIFIER_SU>
			<IDENTIFIER_UD></IDENTIFIER_UD>
			<IDENTIFIER_CA></IDENTIFIER_CA>
			<DATE_4></DATE_4>
			<REF_ON></REF_ON>			
			<PARTY_NAME_1>Vorname Nachname</PARTY_NAME_1>
			<STREET_1>Teststraße</STREET_1>
			<CITY>Test</CITY>
			<POSTAL_CODE>12345</POSTAL_CODE>
			<COUNTRY_CODE>DE</COUNTRY_CODE>			
			<ADD>
				<QUALIFIER></QUALIFIER>
				<IDENTIFIER></IDENTIFIER>
				<AGENCY_CODE></AGENCY_CODE>
				<PARTY_NAME_1></PARTY_NAME_1>
				<STREET_1></STREET_1>
				<CITY></CITY>
				<POSTAL_CODE></POSTAL_CODE>
			</ADD>
			<ADD>
				<QUALIFIER></QUALIFIER>
				<IDENTIFIER></IDENTIFIER>
				<AGENCY_CODE></AGENCY_CODE>
				<PARTY_NAME_1></PARTY_NAME_1>
				<CITY></CITY>
				<POSTAL_CODE></POSTAL_CODE>
			</ADD>
			<ADD>
				<QUALIFIER></QUALIFIER>
				<IDENTIFIER></IDENTIFIER>
				<AGENCY_CODE></AGENCY_CODE>
				<PARTY_NAME_1></PARTY_NAME_1>
				<STREET_1></STREET_1>
				<CITY></CITY>
				<POSTAL_CODE></POSTAL_CODE>
			</ADD>
			<ADD>
				<QUALIFIER>CN</QUALIFIER>
				<IDENTIFIER></IDENTIFIER>
				<AGENCY_CODE></AGENCY_CODE>
				<PARTY_NAME_1>Vorname Nachname</PARTY_NAME_1>
				<STREET_1>Teststraße</STREET_1>
				<CITY>Test</CITY>
				<POSTAL_CODE>12345</POSTAL_CODE>
				<COUNTRY_CODE></COUNTRY_CODE>
				<CONTACT>
					<QUALIFIER></QUALIFIER>
					<NUMBER></NUMBER>
				</CONTACT>
			</ADD>
			<ADD>
				<QUALIFIER></QUALIFIER>
				<IDENTIFIER></IDENTIFIER>
				<AGENCY_CODE></AGENCY_CODE>
				<PARTY_NAME_1></PARTY_NAME_1>
				<STREET_1></STREET_1>
				<CITY></CITY>
				<POSTAL_CODE></POSTAL_CODE>
			</ADD>
			<ADD>
				<QUALIFIER></QUALIFIER>
				<IDENTIFIER></IDENTIFIER>
				<AGENCY_CODE></AGENCY_CODE>
				<PARTY_NAME_1></PARTY_NAME_1>
				<STREET_1></STREET_1>
				<CITY></CITY>
				<POSTAL_CODE></POSTAL_CODE>
				<CONTACT>
					<QUALIFIER></QUALIFIER>
					<NUMBER></NUMBER>
				</CONTACT>
			</ADD>
			<ADD>
				<QUALIFIER></QUALIFIER>
				<IDENTIFIER></IDENTIFIER>
				<AGENCY_CODE></AGENCY_CODE>
			</ADD>
			<TRANSPORT_DETAILS>
				<ADDITIONAL_DETAILS>
					<QUALIFIER></QUALIFIER>
					<DETAILS></DETAILS>
				</ADDITIONAL_DETAILS>
			</TRANSPORT_DETAILS>
			<ITEM>
				<ITEM_NUMBER_EN></ITEM_NUMBER_EN>
				<ITEM_NUMBER_IN></ITEM_NUMBER_IN>
				<ITEM_NUMBER_SA></ITEM_NUMBER_SA>
				<QUANTITY></QUANTITY>
				<QUANTITY_UNIT></QUANTITY_UNIT>
				<LINE_ITEM_NUMBER></LINE_ITEM_NUMBER>
				<AMOUNT_DETAILS>
					<QUALIFIER></QUALIFIER>
					<AMOUNT></AMOUNT>
					<CURRENCY></CURRENCY>
				</AMOUNT_DETAILS>
				<REF>
					<QUALIFIER></QUALIFIER>
					<REFERENCE></REFERENCE>
					<ADDITIONAL_INFO/>
				</REF>
				<REF>
					<QUALIFIER></QUALIFIER>
					<REFERENCE></REFERENCE>
					<ADDITIONAL_INFO/>
				</REF>
				<REF>
					<QUALIFIER></QUALIFIER>
					<REFERENCE></REFERENCE>
					<ADDITIONAL_INFO/>
				</REF>
				<PACKAGE_DETAILS>
					<NUMBER_OF_PACKAGES>1</NUMBER_OF_PACKAGES>
					<REF>
						<QUALIFIER></QUALIFIER>
						<REFERENCE></REFERENCE>
					</REF>
					<REF>
						<QUALIFIER></QUALIFIER>
						<REFERENCE></REFERENCE>
					</REF>
				</PACKAGE_DETAILS>
			</ITEM>
		</GRP>
	</CNT>
</SEEDELFOR>

Hätte es folg. versucht:

<xsl:template match="GRP">
    <xsl:copy>
      <!--copy the data from ADD CN to the GRP -->
      <xsl:for-each  select ="./ADD">
		<xsl:if test="./QUALIFIER='CN'">
          <xsl:apply-templates select="@* | node()"/>
        </xsl:if>
      </xsl:for-each>
	  <!--copy all other nodes-->
      <xsl:apply-templates select="@* | node()"/>
    </xsl:copy>
  </xsl:template>

Hier wird mir jedoch der komplette Inhalt des ADD mit Qualifier CN angeführt und leider nicht unter REF_ON.

Bitte um eure Hilfe.

LG Julian

  1. Hallo, denke die Lösung gefunden zu haben:

    <xsl:template match="GRP">
        <xsl:copy>
    	<!--copy the data from ADD - CN to the GRP so it can be used in the mapping to set the delivery address from end customer-->
          <xsl:for-each  select ="./ADD">
    		<xsl:if test="./QUALIFIER='CN'">
              <xsl:copy-of select="PARTY_NAME_1"/>    
              <xsl:copy-of select="STREET_1"/>
    		  <xsl:copy-of select="CITY"/>
    		  <xsl:copy-of select="POSTAL_CODE"/>
    		  <xsl:copy-of select="COUNTRY_CODE"/>
            </xsl:if>
          </xsl:for-each>
      	  <!--copy all other nodes-->
          <xsl:apply-templates select="@* | node()"/>
        </xsl:copy>
      </xsl:template>
    

    Kann ich jetzt noch die Reihenfolge ändern, dass es nicht unter dem Knoten GRP an erster Stelle sondern bei GRP an letzter Stelle (in diesem Fall REF_ON) ist?

    LG

    1. Hallo,

      ich würde sagen, dass dein XML ein entsprechendes Attribut "pos" benötigt, damit die Reihenfolge klar ist.

      VG Frank