换行不是 xml 到 csv 的结果
New line is not in result of xml to csv
我正在尝试通过 XSLT.When 将 XML 数据转换为 CSV 格式 我正在 XSLT 测试器中测试其工作正常但在 wso2 中不工作。
结果排成一行,而不是每条记录排成一行。
XML数据
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope">
<soapenv:Body>
<dbs:DBSelectResult xmlns:dbs="http://esb.agava.net/mediators/db/dbselect">
<dbs:row>
<dbs:NAME name="NAME">100000007</dbs:NAME>
<dbs:TITLE__C name="TITLE__C">test</dbs:TITLE__C>
<dbs:SHORT_DESCRIPTION__C name="SHORT_DESCRIPTION__C" />
</dbs:row>
<dbs:row>
<dbs:NAME name="NAME">100000005</dbs:NAME>
<dbs:TITLE__C name="TITLE__C">TEST4</dbs:TITLE__C>
<dbs:SHORT_DESCRIPTION__C name="SHORT_DESCRIPTION__C">TEST4</dbs:SHORT_DESCRIPTION__C>
</dbs:row>
</dbs:DBSelectResult>
</soapenv:Body>
</soapenv:Envelope>
XSLT:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:dbs="http://esb.agava.net/mediators/db/dbselect" xmlns:ns="http://org.apache.synapse/xsd" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.0">
<xsl:output method="text" encoding="iso-8859-1"></xsl:output>
<xsl:strip-space elements="*"></xsl:strip-space>
<xsl:template match="//dbs:DBSelectResult/dbs:row">
<xsl:for-each select="child::*">
<xsl:if test="position() != last()">
<xsl:text>'</xsl:text>
<xsl:value-of select="normalize-space(.)"></xsl:value-of>',</xsl:if>
<xsl:if test="position() = last()">
<xsl:text>'</xsl:text>
<xsl:value-of select="normalize-space(.)"></xsl:value-of>
<xsl:text>'</xsl:text>
<xsl:text>
</xsl:text>
</xsl:if>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
当我将此 XSLT 保存为 wso2 中的本地条目时,amp;#xa;由于结果在一行中而不是换行中的每条记录而丢失。
如果您使用 WSO2 Web 控制台,#xa
会丢失:部署此本地条目将文件复制到 repository/deployment/server/synapse-configs/default/local-entries 或部署碳档案。
我正在尝试通过 XSLT.When 将 XML 数据转换为 CSV 格式 我正在 XSLT 测试器中测试其工作正常但在 wso2 中不工作。 结果排成一行,而不是每条记录排成一行。
XML数据
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope">
<soapenv:Body>
<dbs:DBSelectResult xmlns:dbs="http://esb.agava.net/mediators/db/dbselect">
<dbs:row>
<dbs:NAME name="NAME">100000007</dbs:NAME>
<dbs:TITLE__C name="TITLE__C">test</dbs:TITLE__C>
<dbs:SHORT_DESCRIPTION__C name="SHORT_DESCRIPTION__C" />
</dbs:row>
<dbs:row>
<dbs:NAME name="NAME">100000005</dbs:NAME>
<dbs:TITLE__C name="TITLE__C">TEST4</dbs:TITLE__C>
<dbs:SHORT_DESCRIPTION__C name="SHORT_DESCRIPTION__C">TEST4</dbs:SHORT_DESCRIPTION__C>
</dbs:row>
</dbs:DBSelectResult>
</soapenv:Body>
</soapenv:Envelope>
XSLT:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:dbs="http://esb.agava.net/mediators/db/dbselect" xmlns:ns="http://org.apache.synapse/xsd" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.0">
<xsl:output method="text" encoding="iso-8859-1"></xsl:output>
<xsl:strip-space elements="*"></xsl:strip-space>
<xsl:template match="//dbs:DBSelectResult/dbs:row">
<xsl:for-each select="child::*">
<xsl:if test="position() != last()">
<xsl:text>'</xsl:text>
<xsl:value-of select="normalize-space(.)"></xsl:value-of>',</xsl:if>
<xsl:if test="position() = last()">
<xsl:text>'</xsl:text>
<xsl:value-of select="normalize-space(.)"></xsl:value-of>
<xsl:text>'</xsl:text>
<xsl:text>
</xsl:text>
</xsl:if>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
当我将此 XSLT 保存为 wso2 中的本地条目时,amp;#xa;由于结果在一行中而不是换行中的每条记录而丢失。
#xa
会丢失:部署此本地条目将文件复制到 repository/deployment/server/synapse-configs/default/local-entries 或部署碳档案。