我是BizTalk新手,在向输出文件添加名称空间时遇到了问题。
我需要获得以下输出,名称空间位于根级别:
<?xml version="1.0" encoding="utf-8"?>
<TestExternalPO xmlns="http://Test.EDI.TestExternalPO.Schemas">
<Routing/>
<POHeader/>
</TestExternalPO>我的xsd是:
<?xml version="1.0" encoding="utf-16"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:b="http://schemas.microsoft.com/BizTalk/2003"
elementFormDefault="qualified" version="1.0">
<xs:annotation>
<xs:appinfo>
<b:schemaInfo BizTalkServerEditorTool_Version="1.5" root_reference="TestExternalPO"
displayroot_reference="TestExternalPO" standard="XML"
targetNamespace="http://Test.EDI.TestExternalPO.Schemas"
xmlns:b="http://schemas.microsoft.com/BizTalk/2003" />
</xs:appinfo>
</xs:annotation>我的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 select="TestExternalPO"/>
</xsl:template>
<xsl:template match="TestExternalPO">
<TestExternalPO xmlns="http://Test.EDI.TestExternalPO.Schemas">
<Routing>....任何帮助都非常感谢,
Maggs
更新25-4月感谢所有的评论。上面的设置可以工作,但没有给我想要的东西,即根级别的名称空间。
我确实测试了xslt中的名称空间,但在BizTalk上得到了一个错误。
<xsl:template match="TestExternalPO">
<TestExternalPO xmlns="http://Test.EDI.TestExternalPO.Schemas">
<Routing>
<xsl:attribute name="SendPartner">BizTalk错误-按消息类型"http://Test.EDI.TestExternalPO.Schemas“查找文档规范失败。验证架构部署是否正确。
下面是输入文件的结构:
<TestExternalPO>
<POHeader>
</POHeader>
<TradingPartnersList>
<TradingPartners>
</TradingPartners>
</TradingPartnersList>
<Contract>
</Contract>
<ItemsList>
<Items>
</Items>
</ItemsList>
</TestExternalPO>问题出在我声明的'xmlns‘。如果我添加了' targetNamespace ',那么输出的根元素就是targetNamespace。
这是可行的:
<xsl:template match="TestExternalPO">
<TestExternalPO targetNamespace="http://Test.EDI.TestExternalPO.Schemas">
<Routing>
<xsl:attribute name="SendPartner">再次感谢你的帮助。Maggs
发布于 2019-07-05 16:00:48
下面是xslt应该是什么样子。您希望排除命名空间,因此将前缀添加到exclude-result-prefixes
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
exclude-result-prefixes="ns0"
xmlns:ns0="http://Test.EDI.TestExternalPO.Schemas">
<xsl:template match="/">
<xsl:apply-templates select="TestExternalPO"/>
</xsl:template>
<xsl:template match="TestExternalPO">
<ns0:TestExternalPO>
<Routing>.... https://stackoverflow.com/questions/43597637
复制相似问题