首页 > 解决方案 > 无法在 json 转换期间为 xslt 中的单个对象添加数组

问题描述

  ```<?xml version="1.0" encoding="UTF-8"?><xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"   version="1.0"> <xsl:template match="/ "> <xsl:apply-templates mode="body" />    </xsl:template>   <xsl:template match="OneDispatcher" mode="body"><xsl:variable name="header" select="requestPayload/holdDesc"/><taskHeader>  <creator>ON</creator>   <orderInfo>     <lineOfBusiness>IEN-Migration</lineOfBusiness>      <orderSource>IEN-Migration</orderSource>    </orderInfo><taskSource>IEN-Migration</taskSource><userId>wfm</userId></taskHeader><xsl:for-each select="FetchTaskDoc/document-payload/Array"><externalTaskIdList> <xsl:value-of  select="externalTaskId"/></externalTaskIdList></xsl:for-each><holdCode>ONHOLD</holdCode><holdDesc><xsl:value-of select="$header"/></holdDesc></xsl:template></xsl:stylesheet>

above is the xslt code I am using and test1 is the result I am seeing for extenalTaskIdList key in json test2 is externalIdList I am looking for

    ```test1

{“taskHeader”:{“creator”:“ON”,“orderInfo”:{“lineOfBusiness”:“test”,“orderSource”:“test”},“taskSource”:“test”,“userId”:“testing " }, "holdCode": "tetsD", "externalTask​​IdList": "1-9994912", "holdDesc": "Testing"} test2

    "taskHeader": {
        "creator": "ON",
        "orderInfo": {
            "lineOfBusiness": "test",
            "orderSource": "test"
        },
        "taskSource": "test",
        "userId": "testing"
    },
    "holdCode": "tetsD",
    "externalTaskIdList": ["1-9994912"],
    "holdDesc": "Testing"}


标签: javajsonxmluser-interfacexslt

解决方案


推荐阅读