[英]xslt 1.0 match two subsequent elements
我有一個XML文件,並且要在單個段落中插入后續元素
這是XML格式
<root>
<list>
<file> 1.txt </file>
<url> site.com </url>
<file> 2.text </file>
<url> mysite.com </url>
<file> 3.gif </file>
<url> picsite.com </url>
</list>
</root>
我想選擇每兩個后續元素,因此結果將如下所示:
1.txt , site.com
2.txt, mysite.com
3.gif, picsite.com
這看起來很簡單,但是我沒有找到任何優雅的解決方案...有任何建議嗎?
我正在使用XSLT 1.0版本
正如musiKk建議的那樣,
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text" encoding="UTF-8"/>
<xsl:template match="/">
<xsl:for-each select="/root/list/file">
<xsl:value-of select="normalize-space(.)"/>, <xsl:value-of select="normalize-space(following-sibling::*)"/>
<xsl:text>
</xsl:text>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.