【发布时间】:2018-10-11 06:42:17
【问题描述】:
我的 XSLT 映射生成的元素都带有 ns0 前缀。 这是一个例子:
<ns0:EXF_tImportTableLog class="entity">
<ns0:AmountInclVat>2457.7</ns0:AmountInclVat>
<ns0:CompanyId>DC</ns0:CompanyId>
<ns0:Credit>0</ns0:Credit>
我想删除这些前缀。这是我的 XSLT 代码的开始:
<?xml version="1.0" encoding="UTF-16"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:var="http://schemas.microsoft.com/BizTalk/2003/var" exclude-result-prefixes="msxsl var ScriptNS0 userCSharp ScriptNS1" version="1.0" xmlns:st="http://schemas.microsoft.com/dynamics/2008/01/sharedtypes" xmlns:ns0="http://Edi-Portal/Datacon/Documents/PurchaseInvoice" xmlns:ScriptNS0="http://schemas.microsoft.com/BizTalk/2003/ScriptNS0" xmlns:userCSharp="http://schemas.microsoft.com/BizTalk/2003/userCSharp" xmlns:ScriptNS1="http://schemas.microsoft.com/BizTalk/2003/ScriptNS1">
<xsl:output omit-xml-declaration="yes" method="xml" version="1.0" />
<xsl:template match="/">
<xsl:apply-templates select="/ns0:PurchaseInvoice_Cdm_Xml" />
</xsl:template>
<xsl:template match="/ns0:PurchaseInvoice_Cdm_Xml">
我认为我的问题是没有声明默认命名空间,因此映射器会自动将前缀放在每个元素上。我在 Visual Studio 中使用可视化映射器,因此此代码是自动生成的。
输入模式没有这个前缀,所以我不确定为什么会生成它。是否可以在可视化映射器中修复,或者我是否需要更改 XSLT 代码中的某些内容?
【问题讨论】:
-
嗯,为什么?前缀不是实际问题。如果您不想要任何前缀,最好不要使用命名空间。
标签: xml xslt namespaces mapping biztalk