BizTalk - 在属性上放置命名空间? [英] BizTalk - Putting a namespace on an attribute?

查看:24
本文介绍了BizTalk - 在属性上放置命名空间?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

参考这个使用json:Array"的例子:

设置了 FormDefault 的示例架构.

<xs:schema xmlns="http://james.newtonking.com/projects/json";xmlns:b=http://schemas.microsoft.com/BizTalk/2003"attributeFormDefault=合格";targetNamespace=http://james.newtonking.com/projects/json";xmlns:xs=http://www.w3.org/2001/XMLSchema"><xs:元素名称=根"><xs:complexType><xs:序列><xs:complexType><xs:extension base=xs:string"><xs:属性名称=数组"type="xs:boolean";/></xs:extension></xs:simpleContent></xs:complexType></xs:element></xs:sequence></xs:complexType></xs:element></xs:schema>

然而,它不会使命名空间前缀 JSON,而只是默认的 NS0.然而,只要它引用了正确的命名空间,这应该无关紧要.

<Role ns0:Array=true">Role_0</Role></ns0:Root>

Referencing this example of using "json:Array": Converting between JSON and XML

I want BizTalk schema that will build an XML element like this:

  <role json:Array='true'>Admin</role>

I tried adding a schema to my project called FakeJSONArraySchema.xsd, and then on my main schema, I did an "imports". The normal way to use an "imports" is to create a "child record" then change it's "Data Structure Type". But sets that "child record" to the root element of the referenced schema. I just need an attribute.

In the above example, the element "role" needs to be in the namespace of the main schema.

If all else fails, I will try editing the .XSD directly. I was hoping this could be done using the Visual Studio graphical interface.

See related question: Details about the json:Array feature of Newtonsoft.JSON XML to JSON converter

解决方案

As Sprotty has said in his comment, set the Attribute FormDefault or the Attribute Field Form to Qualified to get a namespace prefix on the attribute.

Example schema with FormDefault set.

<?xml version="1.0" encoding="utf-16"?>
<xs:schema xmlns="http://james.newtonking.com/projects/json" xmlns:b="http://schemas.microsoft.com/BizTalk/2003" attributeFormDefault="qualified" targetNamespace="http://james.newtonking.com/projects/json" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:element name="Root">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="Role">
          <xs:complexType>
            <xs:simpleContent>
              <xs:extension base="xs:string">
                <xs:attribute name="Array" type="xs:boolean" />
              </xs:extension>
            </xs:simpleContent>
          </xs:complexType>
        </xs:element>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
</xs:schema>

However it won't make the Namespace prefix JSON, but just the default NS0. However that should hopefully not matter as long as it references the correct namespace.

<ns0:Root xmlns:ns0="http://james.newtonking.com/projects/json">
  <Role ns0:Array="true">Role_0</Role>
</ns0:Root>

这篇关于BizTalk - 在属性上放置命名空间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆