xslt - 以 xslt 中的数字开头
问题描述
条目以数字或“中午”一词开头。这些将成为元素。
结尾嵌套样式字符 () 应放置在节目标题的末尾,以空格标记,后跟以下代码之一:MVLSC、16VLSC、MSC、16VL、ML、MC、PGC、16VL
输入 :
<table>
<tr>
<td> 7.10 Between Worlds 16VLSC 2018 Thriller. Haunted by memories of his deceased family, a truck.</td>
</tr>
<tr>
<td>A look at the latest movie trailers, coming soon to cinemas.</td>
</tr>
</table>
输出 :
<p type="Entry"><tab/>7.10<tab/>Between Worlds<char type="endNestedStyleHere"/> 16VLSC 2018 Thriller. Haunted by memories of his deceased family, a truck.</p>
尝试过的代码:
<xsl:template match="td[starts-with(.,'1234567890')]">
<p>
<xsl:apply-templates/>
</p>
</xsl:template>
我正在使用 XSLT 2.0。谢谢
解决方案
您可以matches
在 XSLT 2.0中使用
<xsl:template match="td[matches(., '^[0-9].*')]">
<p>
<xsl:apply-templates/>
</p>
</xsl:template>
或者,如果数字前可能有空格,您也可能需要检查空格...
<xsl:template match="td[matches(., '^\s*[0-9].*')]">
<p>
<xsl:apply-templates/>
</p>
</xsl:template>
请注意,如果您确实需要 XSLT 1.0 解决方案,您可以这样做...
<xsl:template match="td[contains('0123456789', substring(normalize-space(), 1, 1))]">
推荐阅读
- laravel-livewire - Laravel Livewire $_GET 参数
- node.js - TypeError:params 不是 dockerized 应用程序中的函数
- reactjs - 如何将图像作为背景放置在 React 应用程序中?
- javascript - JavaScript如何用字符串中的换行符替换点
- python - 标签文本不会在 python tkinter 上立即更改
- javascript - webpack 插件中的“应用”是否与 js 中的“应用”相同,这意味着更改它
- reactjs - 检查文件是图像还是视频,并使用正确的标签?
- c++ - 使用 v4l2 在 C++ 中捕获 YUYV
- python - 获取所有指定大小的连续子序列,同时也环绕到前面
- c++ - 使用类和运算符重载计算 3D 中两点之间距离的程序