首页 > 解决方案 > 将值附加到 XSLT 数组中

问题描述

如何从标签外部将数据添加到 xslt 数组中。

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns:map="http://www.w3.org/2005/xpath-functions/map"
    xmlns:array="http://www.w3.org/2005/xpath-functions/array" exclude-result-prefixes="#all"
    version="3.0">
    <xsl:output omit-xml-declaration="yes" indent="yes"/>
    <xsl:param name="input"/>
    
    <xsl:variable name="newline" select="'&#10;'"/>
    <xsl:template match="/" name="xsl:initial-template">
        <xsl:variable name="input-as-map" select="parse-json($input)" as="map(*)"/>
        <root>
            
            <!-- storing all the PERSONNUMBER present in the ibop -->
            <xsl:variable name="item-array" as="element()*">
                    <Item>A</Item>
                    <Item>A</Item>
                    <Item>A</Item>
                    <Item>b</Item>              
            </xsl:variable>   
        </root>
    </xsl:template>    
</xsl:stylesheet>

在这里,我在开头和结尾的变量中添加值<xsl:variable> ..

那么如何将值添加到item-array基于name属性(在变量标签之外)..

就像我们在其他程序中所做的那样……强调文字

标签: xmlxslt

解决方案


那么如何根据名称属性(在变量标签之外)将值添加到项目数组中。

你不能。所有 XSLT 变量都是不可变的。

如果您想要一个具有不同值的变量,请创建一个新变量。


推荐阅读