[英]BizTalk - adding namespace to xml
I'm new to BizTalk and I'm having problems with adding a namespace to my output file. 我是BizTalk的新手,在将名称空间添加到输出文件时遇到问题。
I need to get the following output, with the namespace at the root level: 我需要获得以下输出,并在根级别使用名称空间:
<?xml version="1.0" encoding="utf-8"?>
<TestExternalPO xmlns="http://Test.EDI.TestExternalPO.Schemas">
<Routing/>
<POHeader/>
</TestExternalPO>
My xsd is: 我的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>
My xslt is: 我的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>....
Any help greatly appreciated, 任何帮助,我们将不胜感激,
Maggs 马格斯
Update 25-Apr. 更新4月25日。 Thanks for all the comments.
感谢所有的评论。 The above setup works but doesn't give me what I want ie namespace at root level.
上面的设置有效,但没有给我我想要的东西,即根级别的名称空间。
I did test the namespace in the xslt but got an error on BizTalk. 我确实在xslt中测试了名称空间,但是在BizTalk上出现了错误。
<xsl:template match="TestExternalPO">
<TestExternalPO xmlns="http://Test.EDI.TestExternalPO.Schemas">
<Routing>
<xsl:attribute name="SendPartner">
BizTalk Error - Finding the document specification by message type " http://Test.EDI.TestExternalPO.Schemas " failed. BizTalk错误-通过消息类型“ http://Test.EDI.TestExternalPO.Schemas ”查找文档规范失败。 Verify the schema deployed properly.
验证正确部署的架构。
Below is structure of input file: 下面是输入文件的结构:
<TestExternalPO>
<POHeader>
</POHeader>
<TradingPartnersList>
<TradingPartners>
</TradingPartners>
</TradingPartnersList>
<Contract>
</Contract>
<ItemsList>
<Items>
</Items>
</ItemsList>
</TestExternalPO>
The problem is with my declaration of 'xmlns'. 问题出在我的“ xmlns”声明中。 If I add 'targetNamespace', then output has the targetNamespace at the root element.
如果我添加“ targetNamespace”,则输出在根元素处具有targetNamespace。
This works: 这有效:
<xsl:template match="TestExternalPO">
<TestExternalPO targetNamespace="http://Test.EDI.TestExternalPO.Schemas">
<Routing>
<xsl:attribute name="SendPartner">
Again thanks for the help. 再一次感谢你的帮助。 Maggs
马格斯
Here's how your xslt should look. 这是您的xslt外观。 You want to exclude namespace so add the prefix to exclude-result-prefixes
您要排除名称空间,因此将前缀添加到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>....
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.