gpt4 book ai didi

xslt - XSL if test starts-with

转载 作者:行者123 更新时间:2023-12-03 15:23:57 25 4
gpt4 key购买 nike

鉴于这段 XML

<dc:date>info:eu-repo/date/embargoEnd/2013-06-12</dc:date>
<dc:date>2012-07-04</dc:date>

我需要使用 XSL 仅输出字符串的年份 不以 开头 info:eu-repo .
我正在尝试这种方式,但它不起作用。我错了 for-each ?
<xsl:if test="not(starts-with('dc:date', 'info:eu-repo'))">
<xsl:for-each select="dc:date">
<publicationYear>
<xsl:variable name="date" select="."/>
<xsl:value-of select="substring($date, 0, 5)"/>
</publicationYear>
</xsl:for-each>
</xsl:if>

最佳答案

我猜你不需要 '在您的 start-with查询,并且您可能希望以稍微不同的方式迭代日期:

    <xsl:for-each select="dc:date">
<xsl:variable name="date" select="."/>
<xsl:if test="not(starts-with($date, 'info:eu-repo'))">
<publicationYear>
<xsl:value-of select="substring($date, 0, 5)"/>
</publicationYear>
</xsl:if>
</xsl:for-each>

关于xslt - XSL if test starts-with,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12508566/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com