如何将这些属性格式化为特定的日期字符串变量以便在我的查询中使用?
How do I format these attributes into a specific date string variable for use in my query?
我的 XML 文件中有这个元素:
<MeetingDate Day="29" DayShort="Thu" DayFull="Thursday" Month="4" MonthShort="Apr" MonthFull="April" Year="2021">29 April 2021</MeetingDate>
我想使用 XSLT1 从三个参数构建一个变量:
Year
Month
Day
但我希望月份和日期用零填充。以值 29、4、2021 为例,然后我想要一个变量导致:
2021-04-29
这是因为我需要能够在后续查询中使用该值:
<!-- Now we need to see if they are still available for this actual date -->
<!-- MeetingDate @Year @Month @Day -->
<xsl:variable name="strDate">2021-04-29</xsl:variable>
<xsl:choose>
<xsl:when test="count($PubDB/msa:PublisherDatabase/msa:Publishers/msa:Publisher[msa:Name=$strName]/msa:Availability/msa:DatesNotAvailable/msa:Date[$strDate])=0">
<xsl:text>Still available for this date</xsl:text>
</xsl:when>
<xsl:otherwise>
<em>
<xsl:text>Not available for this date</xsl:text>
</em>
</xsl:otherwise>
</xsl:choose>
目前我将静态文本放入路径中。请注意,我在正确的上下文中只是在我的 XSL 脚本中获取 MeetingDate/@Year
等的值。那么我们要怎么转:
MeetingDate/@Year
MeetingDate/@Month
MeetingDate/@Day
进入 YYYY-MM-DD
变量以便在我的查询中使用?
上下文不是很清楚。尝试类似的东西:
<xsl:variable name="strDate">
<xsl:value-of select="MeetingDate/@Year"/>
<xsl:value-of select="format-number(MeetingDate/@Month, '-00')"/>
<xsl:value-of select="format-number(MeetingDate/@Day, '-00')"/>
</xsl:variable>
我的 XML 文件中有这个元素:
<MeetingDate Day="29" DayShort="Thu" DayFull="Thursday" Month="4" MonthShort="Apr" MonthFull="April" Year="2021">29 April 2021</MeetingDate>
我想使用 XSLT1 从三个参数构建一个变量:
Year
Month
Day
但我希望月份和日期用零填充。以值 29、4、2021 为例,然后我想要一个变量导致:
2021-04-29
这是因为我需要能够在后续查询中使用该值:
<!-- Now we need to see if they are still available for this actual date -->
<!-- MeetingDate @Year @Month @Day -->
<xsl:variable name="strDate">2021-04-29</xsl:variable>
<xsl:choose>
<xsl:when test="count($PubDB/msa:PublisherDatabase/msa:Publishers/msa:Publisher[msa:Name=$strName]/msa:Availability/msa:DatesNotAvailable/msa:Date[$strDate])=0">
<xsl:text>Still available for this date</xsl:text>
</xsl:when>
<xsl:otherwise>
<em>
<xsl:text>Not available for this date</xsl:text>
</em>
</xsl:otherwise>
</xsl:choose>
目前我将静态文本放入路径中。请注意,我在正确的上下文中只是在我的 XSL 脚本中获取 MeetingDate/@Year
等的值。那么我们要怎么转:
MeetingDate/@Year
MeetingDate/@Month
MeetingDate/@Day
进入 YYYY-MM-DD
变量以便在我的查询中使用?
上下文不是很清楚。尝试类似的东西:
<xsl:variable name="strDate">
<xsl:value-of select="MeetingDate/@Year"/>
<xsl:value-of select="format-number(MeetingDate/@Month, '-00')"/>
<xsl:value-of select="format-number(MeetingDate/@Day, '-00')"/>
</xsl:variable>