biztalkbiztalk-2010btahl7biztalk-schemas

how to reference MSH_25_GLO_DEF schema from other assembly/schema


I've built an assembly with the BTAHL7V2X schemas (MSH_25_GLO_DEF, etc).

In another assembly, I need to create a schema, where one of the elements is of type MSH_25_GLO_DEF.

In my BTAHL7V2XCommon assembly I have:

<xs:schema xmlns:b="http://schemas.microsoft.com/BizTalk/2003" xmlns="http://microsoft.com/HealthCare/HL7/2X" targetNamespace="http://microsoft.com/HealthCare/HL7/2X" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:annotation>
    <xs:appinfo>
      <b:schemaInfo root_reference="MSH_25_GLO_DEF" xmlns:b="http://schemas.microsoft.com/BizTalk/2003" />
    </xs:appinfo>
  </xs:annotation>
  <xs:element name="MSH_25_GLO_DEF">
  ...

In my other assembly, I have a schema that look like:

<?xml version="1.0" encoding="utf-16"?>
<xs:schema xmlns="http://mycompany.com/Custom/HL7/2X" xmlns:b="http://schemas.microsoft.com/BizTalk/2003" xmlns:ns0="http://microsoft.com/HealthCare/HL7/2X" targetNamespace="http://mycompany.com/Custom/HL7/2X" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:import schemaLocation="BTAHL7Schemas.MSH_25_GLO_DEF" namespace="http://mycompany.com/Custom/HL7/2X"/>
  <xs:include schemaLocation="ORU_R01_23_GLO_DEF.xsd" />
  <xs:annotation>
    <xs:appinfo>
      <b:schemaInfo standards_version="HL7.DBVersion.1_5" document_type="HL7 2X Schema" version="2.0.0104.0.2.0" root_reference="ORU_R01_23_GLO_DEF" xmlns:b="http://schemas.microsoft.com/BizTalk/2003" />
      <b:references>
        <b:reference targetNamespace="http://mycompany.com/Custom/HL7/2X/2.3/ORU/DataTypes" />
        <b:reference targetNamespace="http://microsoft.com/HealthCare/HL7/2X" />
        <b:reference targetNamespace="http://mycompany.com/Custom/HL7/2X/2.3/ORU/Segments" />
        <b:reference targetNamespace="http://mycompany.com/Custom/HL7/2X/2.3/ORU/Tables" />
      </b:references>
    </xs:appinfo>
  </xs:annotation>
  <xs:element name="ORU_R01_23_ALL">
    <xs:complexType>
      <xs:sequence>
        <xs:element minOccurs="1" maxOccurs="1" name="MSH_25_GLO_DEF" type="ns0:MSH_25_GLO_DEF" />
        <xs:element minOccurs="1" maxOccurs="1" ref="ORU_R01_23_GLO_DEF" />
      </xs:sequence>
    </xs:complexType>
  </xs:element>
</xs:schema>

I've added a reference to the BTAHL7V2X assembly which contains the MSH header and I can see the MSH_25_GLO_DEF if I view the referenced assembly in the object browser, but I always get an error stating "http://microsoft.com/HealthCare/HL7/2X:MSH_25_GLO_DEF is not declared, when I view my schema.

I've also tried changing the imports reference to an include:

<xs:include schemaLocation="BTAHL7Schemas.MSH_25_GLO_DEF" /> 

but get a different error when vieweing the schema:

The targetNamespace 'http://microsoft.com/HealthCare/HL7/2X' of included/redefined schema should be the same as the targetNamespace 'http://mycompany.com/Custom/HL7/2X' of the including schema. 

Is there a proper way to reference BizTalk schema in another assembly?


Solution

  • Check this out: http://social.msdn.microsoft.com/Forums/en-US/biztalkgeneral/thread/d40d2c15-5c91-45c9-877d-2559802d1b1e

    hope that helps

    <xs:schema ... targetNamespace="http://mycompany.com/Custom/HL7/2X">
            <xs:import schemaLocation="BTAHL7Schemas.MSH_25_GLO_DEF" namespace="http://microsoft.com/HealthCare/HL7/2X"/>
        <b:schemaInfo ... root_reference="ORU_R01_23_ALL" ... />