有2321出现的字符'a'在我的源XML文件中的元素含量。
There are 2321 occurrences of the character 'a' in the element contents of my source XML file.
我已经成功地获得了这个号码,但我只能做它的'a'字符。 我需要获得的发生字母表中的所有字母。
I have succeeded in obtaining this number, but I can only do it for the 'a' character. I need to obtain the occurrences for all the letters of the alphabet.
请参阅code:
这是用来打印出一个TextBlock元素:
This is used to print out a TextBlock element:
<xsl:template name="get-textblock">
<xsl:param name="letter-one"/>
<xsl:param name="letter-two"/>
<xsl:param name="letter-one-f"/>
<xsl:param name="letter-two-f"/>
<xsl:if test="$letter-one">
<xsl:number value="$letter-one" format="$letter-one-f"/>
</xsl:if>
<xsl:if test="$letter-two">
<xsl:number value="$letter-two" format="$letter-two-f"/>
</xsl:if>
</xsl:template>
那么,在这种递归循环打印出多少次'a'或'A'发生, 使用XPath EX pression和GET-文本块模板。
Then, in this recursive loop I print out how many times 'a' or 'A' occur, using an XPath expression and the get-textblock template.
<xsl:template name="print-alphabet-value-rows">
<!-- 'letter' is just a counter. -->
<xsl:param name="letter" select="1"/>
<!-- numbers -->
<xsl:param name="letter-one" select="1"/>
<xsl:param name="letter-two" select="1"/>
<!-- format attribute values -->
<xsl:param name="letter-one-f" select=" 'a' "/>
<xsl:param name="letter-two-f" select=" 'A' "/>
<xsl:param name="gridrow">2</xsl:param>
<xsl:param name="gridcol">2</xsl:param>
<xsl:call-template name="get-textblock">
<xsl:with-param name="gridrow" select="$gridrow"/>
<xsl:with-param name="gridcol" select="$gridcol"/>
<xsl:with-param name="style">{StaticResource ValueText}</xsl:with-param>
<xsl:with-param name="letter-one-f" select="$letter-one-f"/>
<xsl:with-param name="letter-two-f" select="$letter-two-f"/>
<xsl:with-param name="letter-one" select="$letter-one"/>
<xsl:with-param name="letter-two" select="$letter-two"/>
<xsl:with-param name="text">
<xsl:value-of select="count(/n-grams-sorted/n-gram[starts-with(.,$letter-one-f) or starts-with(.,$letter-two-f) ])"/>
</xsl:with-param>
</xsl:call-template>
<xsl:if test="$letter < 26">
<xsl:call-template name="print-alphabet-value-rows">
<xsl:with-param name="gridrow" select="$gridrow + 1"/>
<xsl:with-param name="letter" select="$letter +1"/>
<!-- this doesn't work. It prints out the same number of occurrences for all the rows because it only fetches 'a' and 'A', it never increases them -->
<xsl:with-param name="letter-one" select="$letter-one +1"/>
<xsl:with-param name="letter-two" select="$letter-two +1"/>
</xsl:call-template>
</xsl:if>
所以,我在这里做的是我定义一个get-文本块模板绘制TextBlock元素。 然后,我提供下列参数:
So, what I do here is I define a get-textblock template to draw a TextBlock element. Then, I supply the following parameters:
信:一个计数器来简单地去26行向下
letter: a counter to simply go 26 rows down
信一:一些具有格式的一连接到它
letter-one: a number which has a format 'a' attached to it
信二:一些具有格式'A'连接到它
letter-two: a number which has a format 'A' attached to it
我想要做的是不断增加'a'和'A',使相应的XPath EX pression读'B'和什么; 'B','C'和; C等,下至字母表的最后一个字母的所有道路。我不知道要实现这一点。
What I want to do is keep increasing 'a' and 'A', so that the corresponding XPath expression reads 'b' & 'B', 'c' & 'C' etc., all the way down to the last letter of the alphabet. I don't know to accomplish that.
任何想法? 谢谢
我不完全知道我理解的问题,但你可以做的东西类似的东西
I'm not totally sure I understand the question, but can you do anything with something like
translate($letter-one, 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ','bcdefghijklmnopqrstuvwxyzaBCDEFGHIJKLMNOPQRSTUVWXYZA')