XSLT 在 HTML 中嵌入 json

问题描述 投票:0回答:1

我必须将输入作为 JSON 网页并使用 XSLT 将其嵌入到 HTML 中。

输入 JSON 来自此网页

我想将“坐标”数组的内容嵌入到 HTML 页面的脚本标记中。

这是我的实现:

      "type":"Feature",
      "geometry":{
        "type": "Polygon",
        "coordinates":<xsl:variable name="test" select="json-doc('https://deims.org/api/locations/4930521a-596f-4e6f-90b8-29696b8c1c98')"/>
<xsl:value-of select="$test?geometry?coordinates"/>
      }
    }

但仅返回坐标中的数字内容: 8.61638 45.962042 8.642529 45.962042 8.642529 45.949462 8.61638 45.949462 8.61638 45.962042,不带括号或逗号。

json xslt geojson jsondoc
1个回答
0
投票

使用

serialize($test?geometry?coordinates, map { 'method' : 'json' })

© www.soinside.com 2019 - 2024. All rights reserved.