creating arrays in xslt

后端 未结 5 1693
日久生厌
日久生厌 2020-12-30 21:55

can array\'s be created and used in xslt? If so are there suitable examples online to study? If not is there a way to store values in a way that mimics an array?

5条回答
  •  無奈伤痛
    2020-12-30 22:09

    The XPath 2.0 sequence (available in XSLT 2+) is the closest thing to an array:

    (1 to 10)[3]
    

    evaluates to 3

    ('a', 'b', 'a', 'c')[3]
    

    evaluates to 'a'

    The items of a sequence can be of any conceivable type allowed in XPath, with the exception of sequence itself -- nested sequences are not allowed.

    Do note: Sequences are not the same as arrays:

    1. Sequences are immutable. Any updating operation on a sequence (appending or prepending an item, inserting an item or removing an item) produces a new sequence.

    2. The access time to the n-th item is not guaranteed to be O(1) as this is for arrays, and may be O(n).

提交回复
热议问题