xml - 全文链接即将到来
问题描述
嗨,我有以下输入 xml 文件:
<Description>See <XRef href="push">Time</XRef>, <XRef href="back">Late</XRef>, <XRef href="some">Come</XRef></Description>
XSL 我试过上面的代码:
<xsl:template match="Description">
<def>
<para>
<xsl:value-of select="normalize-space(node()[1])"/>
<xsl:if test="XRef">
<xsl:choose>
<xsl:when test="TEST">
<xref>
<xsl:attribute name="endterm">
</xsl:attribute>
<xsl:attribute name="linkend">
</xsl:attribute>
</xref>
</xsl:when>
<xsl:otherwise>
<link>
<xsl:choose>
<xsl:when test="@destination='yes'">
<xsl:attribute name="xlink:href">
<xsl:text>test.pdf</xsl:text>
</xsl:attribute>
</xsl:when>
<xsl:otherwise>
<xsl:attribute name="mark">
</xsl:attribute>
</xsl:otherwise>
</xsl:choose>
<xsl:value-of select="."/>
</link>
</xsl:otherwise>
</xsl:choose>
</xsl:if>
</para>
</def>
</xsl:template>
像这样获取输出:
<def>
<para>See<link mark="">See Time, Late, Come</link></para>
</def>
预期输出如下:
<def>
<para>See <link mark="">Time</link>, <link mark="">Late</link>, <link mark="">Come</link></para>
</def>
我正在获取整个外部参照的链接,但我需要单独的链接。请为此建议一个代码。
解决方案
更改以下代码:-
<xsl:if test="XRef">
**to**
<xsl:for-each select="XRef">
和
</xsl:if>
**to**
</xsl:for-each>
推荐阅读
- python - Python 请求 - 使用分页获取 json 数据
- microsoft-graph-api - 如何获取在线会议的通讯呼叫 ID?
- reactjs - 用于 API 函数的 useEffect 或 useMemo?
- azure-data-explorer - KQL 用于在 Azure 门户中查找过去 90 天未登录的非活动用户
- java - 有没有办法可以在我的 Java 程序中转换变量,以便获得双重输出?
- .htaccess - .htaccess 禁止通过不带扩展名的路径访问文件
- javascript - :class="`level ${file.invalidMessage && 'has-text-danger'}`" 是如何崩溃的?
- css - 使用 :not() 选择器对不在内部的元素进行样式设置
元素
- android - 在关闭 GPS 的情况下获取 Android 中的最后一个已知位置
- python - 熊猫每次计数 (XX:XX:XX) 基于条件