XSL:在由多个TEI-XML元素组成的字符串中添加指向子字符串的链接
几天后,我尝试在一个字符串中添加子字符串XSL:在由多个TEI-XML元素组成的字符串中添加指向子字符串的链接,xml,xslt,xslt-3.0,tei,Xml,Xslt,Xslt 3.0,Tei,几天后,我尝试在一个字符串中添加子字符串w[@type='verb']的链接。 我正在研究粘土片的TEI-XML音译,因此中的元素和@type的顺序并不总是相同的 XSLT3.0版: <?xml version="1.0" encoding="UTF-8"?> <xsl:template match="/"> <xsl:apply-templates select="//div1"/> </xsl:template> <xsl:temp
w[@type='verb']
的链接。
我正在研究粘土片的TEI-XML
音译,因此
中
的元素和@type
的顺序并不总是相同的
XSLT
3.0版:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:template match="/">
<xsl:apply-templates select="//div1"/>
</xsl:template>
<xsl:template match="//div1">
<!-- additional content before <ul> -->
<ul>
<li>
<xsl:for-each select="descendant-or-self::lg/l[@n]">
<xsl:variable name="verb1" select="w[@type='verb']"/>
<xsl:variable name="href1" select="w[@type='verb']/@lemmaRef"/>
<xsl:variable name="single-l" select="w[@type='coo'] | w[@type='noun'] | w[@type='verb'] | w[@type='num'] | w[@type='adv'] | w[@type='adj'] | g | name"/>
<xsl:value-of select="$single-l"/>
<sup><xsl:value-of select="./@n"/></sup>
</xsl:for-each>
</li>
</ul>
</xsl:template>
我需要展示:
<ul>
<li>w <a href="uga/verb.xml#qry">tqry</a> . ġlmm št . ġr .<sup>4b-5a</sup></li>
</ul>
- w。ġlmmšt。ġr.4b-5a
“tqry”是
中包含的动词
如何在XSLT
中显示
。我尝试了替换$single-l
的或者为以前的XSLT
代码定义一个新变量,但没有成功。我也尝试过使用键
,但我认为我仍然存在理解问题
首先,感谢您的善意建议。我认为您不应该尝试构建一个字符串,然后在其中插入标记,似乎可以简单地处理子元素,然后在lg/l[@n]/w[@type='verb']]上进行匹配,以将其转换为HTML超链接:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
exclude-result-prefixes="xs"
version="3.0">
<xsl:output method="html" indent="yes" html-version="5"/>
<xsl:strip-space elements="*"/>
<xsl:template match="/">
<html>
<head>
<title>Example</title>
</head>
<xsl:apply-templates/>
</html>
</xsl:template>
<xsl:template match="div">
<section>
<ul>
<xsl:apply-templates select=".//lg/l[@n]"/>
</ul>
</section>
</xsl:template>
<xsl:template match="lg/l[@n]">
<li>
<xsl:apply-templates/>
<sup>
<xsl:value-of select="@n"/>
</sup>
</li>
</xsl:template>
<xsl:template match="lg/l[@n]/w[@type = 'verb']">
<a href="{@lemmaRef}">
<xsl:apply-templates/>
</a>
</xsl:template>
<xsl:template match="space">
<xsl:text> </xsl:text>
</xsl:template>
</xsl:stylesheet>
例子
这目前并没有产生想要的结果,但是
<li>w <a href="uga/verb.xsl#qry">tqry</a>.ġlmmb št.ġr.<sup>4b-5a</sup></li>
w.ġlmmbšt.ġr.4b-5a
相反,如果您不需要或不想要某个元素的内容,您可以为该元素添加一个空模板,这样它就不会产生任何输出(例如,
)
我不确定是否也缺少重要的空白,插入空白的规则是什么,您可能需要解释一下
在线样品位于。太好了!我已经寻找了几个小时的解决方案,当它看起来如此简单。。。!!我不知道部分
。由于存在
,因此缺少空白并非真正的问题。但也许使用正则表达式,我可以添加空白。如果我找到了正确的答案,我会查看并发布。
<li>w <a href="uga/verb.xsl#qry">tqry</a>.ġlmmb št.ġr.<sup>4b-5a</sup></li>