Вы можете использовать элемент xsl:attribute
здесь ...
<ZipCodeHome>
<xsl:attribute name="PriorValue" select="ws:Personal/ws:Address_Data[ws:Address_Type='HOME']/ws:Postal_Code/@ws:PriorValue" />
<xsl:value-of select="ws:Personal/ws:Address_Data[ws:Address_Type='HOME']/ws:Postal_Code"/>
</ZipCodeHome>
Но вы также можете использовать шаблоны значений атрибутов ....
<ZipCodeHome PriorValue="{ws:Personal/ws:Address_Data[ws:Address_Type='HOME']/ws:Postal_Code/@ws:PriorValue}">
<xsl:value-of select="ws:Personal/ws:Address_Data[ws:Address_Type='HOME']/ws:Postal_Code"/>
</ZipCodeHome>
Но если это возможноатрибуты, отличные от PriorValue
, которые вы хотите скопировать, подумайте о написании универсального шаблона для их обработки
<xsl:template match="@*">
<xsl:attribute name="{local-name()}" select="." />
</xsl:template>
Тогда вы бы написали это ...
<ZipCodeHome>
<xsl:apply-templates select="ws:Personal/ws:Address_Data[ws:Address_Type='HOME']/ws:Postal_Code/@*" />
<xsl:value-of select="ws:Personal/ws:Address_Data[ws:Address_Type='HOME']/ws:Postal_Code"/>
</ZipCodeHome>
Но в любом случае,XSLT имеет много повторений с выражениями XPath, поэтому рассмотрите возможность использования сопоставления с шаблоном вместо того, чтобы сократить время ....
Попробуйте это XSLT
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:ws="urn:com.workday/workersync" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.0">
<xsl:output encoding="utf-16" method="xml" indent="yes" />
<xsl:template match="ws:Worker_Sync">
<Root>
<xsl:apply-templates select="ws:Worker" />
</Root>
</xsl:template>
<xsl:template match="ws:Worker">
<Worker>
<xsl:apply-templates select="ws:Personal" />
<xsl:apply-templates select="ws:Personal/ws:Address_Data[ws:Address_Type='HOME']" />
<Contract>
<ContractType>
<xsl:value-of select="if (ws:Position/ws:Worker_Type = 'Permanent') then '01' else '02'"/>
</ContractType>
<ContractTypeText>
<xsl:value-of select="if (ws:Position/ws:Worker_Type = 'Permanent') then 'Vakituinen' else 'Määräaik. sopimus'"/>
</ContractTypeText>
<ProbationEndDate>
<xsl:value-of select="format-date(xs:date(ws:Status/ws:Probation_End_Date), '[Y0001][M01][D01]')"/>
</ProbationEndDate>
</Contract>
</Worker>
</xsl:template>
<xsl:template match="ws:Personal">
<Personal>
<BirthDate>
<xsl:value-of select="format-date(xs:date(ws:Birth_Date), '[Y0001][M01][D01]') "/>
</BirthDate>
<FirstName>
<xsl:value-of select="concat(ws:Name_Data[ws:Name_Type='Legal']/ws:First_Name, ws:Name_Data[ws:Name_Type='Legal']/ws:Middle_Name)"/>
</FirstName>
<Gender>
<xsl:value-of select="if (ws:Gender='Male') then '1' else '2'"/>
</Gender>
<GenderText>
<xsl:apply-templates select="ws:Gender"/>
</GenderText>
<Initials>
<xsl:value-of select="concat(ws:Name_Data[ws:Name_Type='Preferred']/ws:First_Name, ' ', ws:Name_Data[ws:Name_Type='Preferred']/ws:Last_Name)"/>
</Initials>
<Language>
<xsl:apply-templates select="ws:Birth_Date"/>
</Language>
<LastName>
<xsl:apply-templates select="ws:Name_Data[ws:Name_Type='Legal']/ws:Last_Name"/>
</LastName>
<Ssn>
<xsl:apply-templates select="ws:Identification_Data[ws:Identification='National']/ws:ID"/>
</Ssn>
</Personal>
</xsl:template>
<xsl:template match="ws:Address_Data">
<Contact_Details>
<CityHome>
<xsl:apply-templates select="ws:Submunicipality" />
</CityHome>
<CountryHome>
<xsl:apply-templates select="ws:Country"/>
</CountryHome>
<StreetAddressHome>
<xsl:apply-templates select="ws:Address_Line_Data"/>
</StreetAddressHome>
<ZipCodeHome>
<xsl:apply-templates select="ws:Postal_Code"/>
</ZipCodeHome>
</Contact_Details>
</xsl:template>
<xsl:template match="*">
<xsl:apply-templates select="@*" />
<xsl:value-of select="."/>
</xsl:template>
<xsl:template match="@*">
<xsl:attribute name="{local-name()}" select="." />
</xsl:template>
</xsl:stylesheet>