尽管我尝试了许多写这些count()行的方法,但我仍无法使Xslt表正常工作。
查看下面的代码,然后再尝试。 我试过了 : (1)
<xsl:for-each select="Trans/Episode/Section/Turn/tour">
<tr>
<td><xsl:value-of select="count(motBDL[@lexeme='JE'])" /></td>
</tr>
</xsl:for-each>
(2)
<td><xsl:value-of select="count(motBDL[lexeme='JE'])" /></td>
(3)
<xsl:for-each select="Trans">
<td><xsl:value-of select="count(/Episode/Section/Turn/tour/motBDL[@lexeme='JE'])" /></td>
(4)`
与(5; 6; 7; 8)“()”相同,而不是“ []”
XML =
<!--The entire code is correct (just for you to understand what I am trying to extract)-->
<?xml version="1.0" encoding="UTF8" standalone="yes"?>
<?xml-stylesheet type="text/xsl" href="Projet-Info.xsl"?>
<!DOCTYPE Trans SYSTEM "trans-corpus.dtd">
<Trans scribe="computer-name" audio_filename="Debat Hollande Sarkozy 1998" video_filename="" version="8" version_date="181221">
<Speakers>
<Speaker name="Nicolas Sarkozy" check="yes"/>
<Speaker name="François Hollande" check="yes"/>
<Speaker name="Journaliste" check="no"/>
<Speaker name="Journaliste 2" check="no"/>
</Speakers>
<Episode>
<Section type="report" startTime="0" endTime="1408.652">
<Sync time="0.152"/>
<Turn speaker="spk1" startTime="0.152" endTime="3.038">
<tour nbmots="6" id="000000">
<motBDL lexeme="POUR" phon="puʁ">pour</motBDL>
<motBDL lexeme="MOI" phon="mwa">moi</motBDL>
<motBDL lexeme="JE" phon="ʒə">je</motBDL>
<motBDL lexeme="NE" phon="nə">ne</motBDL>
<motBDL lexeme="SAVOIR" phon="save">savais</motBDL>
<motBDL lexeme="PAS" phon="pa">pas</motBDL>
</tour>
</Turn>
</Section>
</Episode>
</Trans>
XSL =
<!--Code b4 is correct-->
<table border="2" style="text-align: center;">
<tr>
<!--<th>nom</th>-->
<th>je</th>
</tr>
<xsl:for-each select="Trans">
<xsl:if test="not(@check='no')">
<tr>
<td><xsl:value-of select="Speakers/Speaker/@name" /></td>
<td><xsl:value-of select="count(Episode/Section/Turn/tour/motBDL[@lexeme='JE'])" /></td>
</tr>
</xsl:if>
</xsl:for-each>
</table>
<!--Code after is correct-->
<!--I expect when I run my program on firefox to actually run.-->
答案 0 :(得分:0)
您已经用正斜杠开始了表达。...
CoreMotion
这意味着xpath表达式将相对于文档节点,而不是相对于您当前所在的节点。你应该这样做...
/Episode/Section/Turn/tour/motBDL[@lexeme='JE']
您也有同样的疑问
<xsl:value-of select="count(Episode/Section/Turn/tour/motBDL[@lexeme='JE'])" />
这也指的是不存在的属性。如果要在此处编写<xsl:value-of select="/Speakers/Speaker/@nom" />
,请记住,在XSLT 1.0中,如果执行@name
并选择多个节点,则仅输出第一个。
另外,请注意,您的XSLT中有两个xsl:value-of
指令。我不确定这是允许的.....