json - 如何使用 XSLT 将 JSON 请求转换为 XML?
问题描述
我们以 JSON 形式接收具有不同值的输入请求。我必须使用 XSLT 1.0 将传入请求转换为 XML。我尝试使用带有函数 json-to-xml() 的 XSLT 3.0 进行转换,但它对我不起作用。我应该如何使用 XSLT 1.0 版转换传入请求?
要求:
{
"Text": [
{
"from": "9878744785",
"to": "998777945"
}
]
}
预期反应:
<?xml version="1.0" encoding="UTF-8"?>
<Text>
<from>9878744785</from>
<to>998777945</to>
</Text>
XSLT 我试过:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
exclude-result-prefixes="xs"
version="3.0">
<xsl:output indent="yes"/>
<xsl:template match="/">
<xsl:copy-of select="json-to-xml(root)"/>
</xsl:template>
</xsl:stylesheet>
解决方案
推荐阅读
- python-3.x - 如何将我的时间范围数据保存到 InfluxDB?
- variables - 如何将变量作为参数、对象类型传递给 Azure DevOps 模板
- c# - 根据来自一般请求的模式映射外部 api 请求
- apache-kafka - 允许带有前缀的 Kafka 用户写入主题
- powershell - Powershell - ActiveDirectory 为 OU 中的所有用户查找 LastLogon 和 Manager
- r - 检测相同 id 中的不同值
- twitter-bootstrap - Bootstrap 5 添加 bs-gutter x 1.5rem 这使得
和其他标记挂起 - python - 有没有最简单的方法来解决如下所述的功能代码
- c# - 无法在我的 DataTemplate 中使用附加属性
- php - 如何不显示空集合