0

One destination system requires that the xml for import contains xsi:schemaLocation="targetNS targetNS.xsd" as an attribute on the root node.

How can we accomplish this with BizTalk? Could it be done as a demand in the schema, by a map or do we have to use a pipeline?

The outgoing xml is suppose to look like this:

<?xml version="1.0" encoding="utf-8"?>
<root xmlns="targetNS" 
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="targetNS targetNS.xsd">
Martin Bring
  • 1,136
  • 1
  • 7
  • 17
  • I think they are confusing XML instances and XSD schemas, as xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" and xsi:schemaLocation is what you have in Schemas, not XML payloads – Dijkgraaf Apr 04 '22 at 04:53

1 Answers1

0

The below schema will generate an attribute with the value at the root node. However the namespace prefix will be the default ns0: one, xmlns:xsi is Namespace (prefix) related attributes in XML and XML Schema (XSD). One of the settings to change from the default is the attributeFormDefault to qualified.

<?xml version="1.0" encoding="utf-16"?>
<xs:schema xmlns:b="http://schemas.microsoft.com/BizTalk/2003" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="targetNS" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:element name="root">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="test" type="xs:string" />
      </xs:sequence>
      <xs:attribute default="targetNS targetNS.xsd" name="schemaLocation" type="xs:string" />
    </xs:complexType>
  </xs:element>
</xs:schema>

Which generates as

<ns0:root ns0:schemaLocation="targetNS targetNS.xsd" xmlns:ns0="targetNS">
  <ns0:test>test_0</ns0:test>
</ns0:root>
Dijkgraaf
  • 10,108
  • 17
  • 36
  • 52