简体   繁体   中英

How to create key-value string sequence from another plain sequence in XPath 2.0

I needs an XSLT function to create key-value strings sequence ( 'key1_val1', 'key2_val2', 'key3_val3' ) from plain strings sequence ( 'key1', 'val1', 'key2', 'val2', 'key3', 'val3' ) .

I was stopped on the following code and have no ideas to continue:

<xsl:function name="bx:generate-pairs" as="xs:string*">
    <xsl:param name="seq" as="xs:string*"/>
    <xsl:sequence select="for $key in $seq return ..."/>
</xsl:function>

XSLT processor Saxon 9.3

你在找

for $i in (1 to count($seq))[. mod 2 = 1] return concat($seq[$i], '_', $seq[$i + 1])

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM