I want to select the next sibling of an attribute for outputting the period. This template is selecting the required attributes.
The only solution that works is the one where i match the name of the attribute and selecting the one i need. How can i make it more general, using few line? I've tried with 'following-sibling' but that works just for elements.
The piece of the functional code;
...
<Period >
<xsl:attribute name="Unit">
<xsl:choose>
<xsl:when test="local-name()='BonusAmount'">
<xsl:value-of select="../@BonusFrequency"/>
</xsl:when>
<xsl:when test="local-name()='CommissionAmount'">
<xsl:value-of select="../@CommissionFrequency"/>
</xsl:when>
<xsl:when test="local-name()='GrossRegularOvertimeAmount'">
<xsl:value-of select="../@GrossRegularOvertimeFrequency"/>
</xsl:when>
<xsl:when test="local-name()='GrossSalaryAmount'">
<xsl:value-of select="../@GrossSalaryFrequency"/>
</xsl:when>
<xsl:when test="local-name()='CarAllowanceAmount'">
<xsl:value-of select="../@CarAllowanceFrequency"/>
</xsl:when>
<xsl:when test="local-name()='WorkAllowanceAmount'">
<xsl:value-of select="../@WorkAllowanceFrequency"/>
</xsl:when>
<xsl:when test="local-name()='WorkersCompensationAmount'">
<xsl:value-of select="../@WorkersCompensationFrequency"/>
</xsl:when>
</xsl:choose>
</xsl:attribute>
</Period>
...
XML sample:
<Employment>
<PAYG Basis="Temporary" Industry="Oil and Gas Extraction" IndustryCode="0700" Occupation="General Waiter" OccupationCode="6323-11" OnProbation="Yes" ProbationDateEnds="2019-03-27" StartDate="2014-05-05" Status="Secondary" UniqueID="c8492d8c-34fc-419b-93f4-f1f3" x_Employer="c46c9077-31ef-4daa-b8cc-c9e3">
<Income BonusAmount="89898985" BonusFrequency="Monthly" CommissionAmount="4488" CommissionFrequency="Yearly" GrossRegularOvertimeAmount="365" GrossRegularOvertimeFrequency="Fortnightly" GrossSalaryAmount="4798" GrossSalaryFrequency="Weekly" WorkAllowanceAmount="10101010" WorkAllowanceFrequency="Monthly"/>
</PAYG>
</Employment>
The output:
<ValueItem Value="89898985">
<Identifier UniqueID="c8492d8c-34fc-419b-93f4-f1f3-Income-PAYG-BonusAmount"/>
<PercentOwned Percent="100">
<RelatedEntityRef RelatedID="baaef85e-3793-4fe8-8c62-8cc766fa490b"/>
</PercentOwned>
<Income Type="Bonus">
<Period Unit="Monthly"/>
<RelatedEntityRef RelatedID="c46c9077-31ef-4daa-b8cc-c9e3"/>
</Income>
</ValueItem>
<ValueItem Value="4488">
<Identifier UniqueID="c8492d8c-34fc-419b-93f4-f1f3-Income-PAYG-CommissionAmount"/>
<PercentOwned Percent="100">
<RelatedEntityRef RelatedID="baaef85e-3793-4fe8-8c62-8cc766fa490b"/>
</PercentOwned>
<Income Type="Commission">
<Period Unit="Yearly"/>
<RelatedEntityRef RelatedID="c46c9077-31ef-4daa-b8cc-c9e3"/>
</Income>
</ValueItem>
<ValueItem Value="365">
<Identifier UniqueID="c8492d8c-34fc-419b-93f4-f1f3-Income-PAYG-GrossRegularOvertimeAmount"/>
<PercentOwned Percent="100">
<RelatedEntityRef RelatedID="baaef85e-3793-4fe8-8c62-8cc766fa490b"/>
</PercentOwned>
<Income Type="GrossRegularOvertime">
<Period Unit="Fortnightly"/>
<RelatedEntityRef RelatedID="c46c9077-31ef-4daa-b8cc-c9e3"/>
</Income>
</ValueItem>
<ValueItem Value="4798">
<Identifier UniqueID="c8492d8c-34fc-419b-93f4-f1f3-Income-PAYG-GrossSalaryAmount"/>
<PercentOwned Percent="100">
<RelatedEntityRef RelatedID="baaef85e-3793-4fe8-8c62-8cc766fa490b"/>
</PercentOwned>
<Income Type="GrossSalary">
<Period Unit="Weekly"/>
<RelatedEntityRef RelatedID="c46c9077-31ef-4daa-b8cc-c9e3"/>
</Income>
</ValueItem>
etc.