Ich versuche, einen Wert von einer Vorlage an eine andere Vorlage zu übergeben. Obwohl ich ein paar Beispiele in diesem Forum gefunden habe, kann ich es einfach nicht machen.Werte von einer Vorlage zu einer anderen übergeben
Unten ist mein XML:
<pi:PayGroup xmlns:pi="urn:com.sample/file">
<pi:Header>
<pi:Version>17</pi:Version>
<pi:Payroll_Company_Name>ABCD</pi:Payroll_Company_Name>
<pi:Pay_Group_ID>0307</pi:Pay_Group_ID>
</pi:Header>
<pi:Employee>
<pi:Summary>
<pi:Employee_ID>12345678</pi:Employee_ID>
<pi:Name>Test Employee</pi:Name>
</pi:Summary>
<pi:Position>
<pi:Business_Title>Lead Learning Specialist</pi:Business_Title>
<pi:Worker_Type>P</pi:Worker_Type>
<pi:Position_Time_Type>Full_time</pi:Position_Time_Type>
<pi:Compensation_Effective_Date>2017-07-01</pi:Compensation_Effective_Date>
<pi:Base_Pay_Currency>EUR</pi:Base_Pay_Currency>
<pi:Base_Pay_Frequency>4-Weekly</pi:Base_Pay_Frequency>
<pi:Organization_One>0307_3075999496</pi:Organization_One>
<pi:Organization_Two>0307</pi:Organization_Two>
<pi:Supervisor_ID>00295975</pi:Supervisor_ID>
<pi:Supervisor_Name>Simba Sang (98765432)</pi:Supervisor_Name>
</pi:Position>
<pi:Earnings>
<pi:Start_Date>2017-02-06</pi:Start_Date>
<pi:Currency>EUR</pi:Currency>
</pi:Earnings>
</pi:Employee>
</pi:PayGroup>
Unten ist die XSLT, die für eine lange Zeit in Gebrauch ist:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:pi="urn:com.workday/picof"
version="2.0">
<xsl:output omit-xml-declaration="yes" method="xml"/>
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<!-- 0... 123456 -->
<xsl:template match="pi:Employee_ID">
<pi:Employee_ID>
<xsl:value-of select="substring(.,3)"/>
</pi:Employee_ID>
</xsl:template>
<xsl:template match="pi:Supervisor_ID">
<pi:Supervisor_ID>
<xsl:value-of select="substring(.,3)"/>
</pi:Supervisor_ID>
</xsl:template>
<xsl:template match="pi:Supervisor_Name">
<pi:Supervisor_Name>
<xsl:value-of select="normalize-space(substring-before(.,'('))"/>
</pi:Supervisor_Name>
</xsl:template>
<xsl:template match="pi:Organization_One">
<pi:Organization_One>
<xsl:value-of select="if(contains(.,'_'))
then(normalize-space(substring-after(.,'_')))
else(.)"/>
</pi:Organization_One>
</xsl:template>
</xsl:stylesheet>
hier fragen ist, dass/pi: Position/pi: Compensation_Effective_Date Wert sollte auch unter/pi: Earnings_Deductions/pi: Start_Date tag
pi: Start_Datum sollte den gleichen Wert wie pi haben: Compensation_Effective_Date.
so modifiziert, I die XSLT zwei weitere Schablonenübereinstimmung eine für PI enthalten: Compensation_Effective_Date und andere für/pi: start_date wie unten gezeigt:
<xsl:template match="/pi:Compensation_Effective_Date">
<xsl:param name="test"/>
<xsl:apply-templates>
<xsl:with-param name="test" select="."/>
</xsl:apply-templates>
<pi:Compensation_Effective_Date><xsl:value-of select="$test"/></pi:Compensation_Effective_Date>
</xsl:template>
<xsl:template match="pi:Start_Date">
<xsl:param name="test"/>
<pi:Start_Date><xsl:value-of select="$test"/></pi:Start_Date>
</xsl:template>
Hatte einen Param Wert in pi: compensation_effective_date Template und weitergegeben Dieser Parameter zu pi: start_date Vorlage. Aber das pi: Start_Date ist immer leer; Wie kann ich den Wert compensation_effective_Date auch in start_date erhalten?
Erwartete Ausgabe:
<pi:Position>
<pi:Business_Title>...</pi:Business_Title>
<pi:Worker_Type>..</pi:Worker_Type>
<pi:Position_Time_Type>..</pi:Position_Time_Type>
<pi:Compensation_Effective_Date>2017-07-01</pi:Compensation_Effective_Date>
<pi:Base_Pay_Currency>..</pi:Base_Pay_Currency>
<pi:Base_Pay_Frequency>...</pi:Base_Pay_Frequency>
<pi:Organization_One>....</pi:Organization_One>
<pi:Organization_Two>....</pi:Organization_Two>
<pi:Supervisor_ID>....</pi:Supervisor_ID>
<pi:Supervisor_Name>.....</pi:Supervisor_Name>
</pi:Position>
<pi:Earnings>
<pi:Start_Date>2017-07-01</pi:Start_Date>
<pi:Currency>...</pi:Currency>
</pi:Earnings>
Ich schlage vor, Sie reduzieren das Beispiel auf das Minimum, das erforderlich ist, um das Problem zu demonstrieren - siehe: [MCVE]. –