xsl - 从符号20到符号30的第二行拾取字符串

时间:2016-09-26 15:01:49

标签: xslt

<msg>
I told my son, “You will marry the girl I choose.” He said, “NO!” 
I told him, “She is Bill Gates’ daughter.” He said, “OK.” 
I called Bill Gates and said, “I want your daughter to marry my son.” 
Bill Gates said, “NO.” I told Bill Gates, My son is the CEO of World Bank.” Bill Gates said, “OK.” I called the President of World Bank and asked him to make my son the CEO. He said, “NO.” I told him, “My son is Bill Gates’ son-in-law.” He said, “OK.” This is exactly how politics works . . .
</msg>

我想从第一排10点到20号拿起标志 从9到19从二线和 5至15和18至21从第三行

所以我很喜欢

<line1> son, “You </line1>
<line2> im, “She </line2>
<line3> lled Bill Gates d sa</line3>

所以选择一行从10到20的行包括空 - 像xsl中的那样:) 这样想是可能的吗?

1 个答案:

答案 0 :(得分:1)

XSLT 2.0 中,您可以执行以下操作:

<xsl:template match="msg">
    <xsl:variable name="lines" select="tokenize(., '&#10;')" />
    <line1>
        <xsl:value-of select="substring($lines[1], 10, 10)" />
    </line1>
    <line2>
        <xsl:value-of select="substring($lines[2], 9, 10)" />
    </line2>
    <line3>
        <xsl:value-of select="substring($lines[3], 5, 10)" />
    </line3>
</xsl:template>