我有一個包含如下行的文本檔案:
ABC
DEF
GHI
JKL
MNO
PQR
STU
VWX
YZA
所以我用 XSLT-3.0 讀取了這個檔案的行,fn:unparsed-text-lines('fileName','UTF-8')我想用以下以空格開頭的行組合/合并這些行并將它們包裝在元素中。例如,使用xsl:for-each-group:
<line>ABC</line>
<line>DEF GHI</line>
<line>JKL MNO PQR STU</line>
<line>VWX</line>
<line>YZA</line>
但是我不知道如何使用與 XSLT-3.0xsl:for-each-group的序列xs:strings。我是否必須先將字串轉換為節點?或者,還有更好的方法?
這是功能失調的 XSLT 嘗試(謂詞只是一個提示,不起作用):
<xsl:for-each-group select="unparsed-text-lines('filename.txt','utf-8')" group-starting-with="text()[not(starts-with(.,' '))]">
<line><xsl:value-of select="string-join(current-group(),'DELIMITER')"/></line>
</xsl:for-each-group>
uj5u.com熱心網友回復:
字串不是文本節點。試試這個方法:
<xsl:for-each-group select="$lines" group-starting-with=".[not(starts-with(.,' '))]">
<line>
<xsl:value-of select="current-group()" separator=""/>
</line>
</xsl:for-each-group>
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/334364.html
上一篇:htmlepg到xml通過php
