如何在XSLT版本3.0上编写代码来计算仅工作日(即排除星期六和星期天)?

huangapple go评论63阅读模式
英文:

How to create code on XSLT in ver 3.0 to calculate only business days (i.e excluding Saturday and Sunday )?

问题

I can help you with the translation:

我有这段代码。
我想要将其转换为XSLT(版本3.0),只返回一个值,如下所示。逻辑是星期五 - 2023-03-10,星期二 - 2023-03-14。相差4个日历日。但是,我想要收到值2(不包括周六和周日)“工作日”。

能否协助使用XPath?我的意思是我想在模板中的某处使用XPath,以仅计算工作日之间的差异(/trade/exerciseDate/adjustedDate - 第1天和/trade/cashPaymentDate/adjustedDate - 第2天)。

我的目标是创建一个模板,只能使用XPath逻辑来计算我所展示的工作日期。

I've translated your text, keeping the code parts as requested. If you have any further questions or need assistance with XPath, feel free to ask.

英文:

I have this code.

<trade>
	<exerciseDate>
		<adjustedDate>2023-03-10</adjustedDate>
	</exerciseDate>
	<cashPaymentDate>
		<adjustedDate>2023-03-14</adjustedDate>
	</cashPaymentDate>
    <currency>EUR</currency>
<effectiveDate>
	<adjustedDate>2023-03-14</adjustedDate>
	<dateAdjustments>
		<businessDayConvention>NONE</businessDayConvention>
	</dateAdjustments>
</effectiveDate>
<terminationDate>
	<unadjustedDate>2024-03-14</unadjustedDate>
		<dateAdjustments>
            <businessDayConvention>MODFOLLOWING</businessDayConvention>
		</dateAdjustments>
</terminationDate>
</trade>

I would like to receive as XSLT (ver.3.0) only 1 value. Like below. The logic is Friday - 2023-03-10,
Tuesday -2023-03-14. Difference 4 Calendar Days. But I would like to receive value 2 ( that excluding Saturday and Sunday ) 'Business Days'

<workingDate>2</workingDate>

Can you please assist with using XPath's? I mean I want to use there XPath somewhere in template, that can calculate difference only in Business Days(/trade/exerciseDate/adjustedDate - 1st day and
/trade/cashPaymentDate/adjustedDate - 2nd day )

My goal is to create a template where I can only calculate the working dates that I have shown but using Xpath logic

答案1

得分: 1

你应该能够使用以下表达式:

my:workdays-in-range(/trade/exerciseDate/adjustedDate, trade/cashPaymentDate/adjustedDate )

在定义了如你之前的问题中所示的必要函数之后。

英文:

You should be able to use the expression:

my:workdays-in-range(/trade/exerciseDate/adjustedDate, trade/cashPaymentDate/adjustedDate )

after defining the necessary functions as shown in your previous question.

huangapple
  • 本文由 发表于 2023年3月15日 21:31:51
  • 转载请务必保留本文链接:https://go.coder-hub.com/75745415.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定