Announcement

Collapse
No announcement yet.

XML Namespace

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • XML Namespace

    It is obvious that I do not understand namespaces yet.

    I’m running Mirth Connect 2.0.1.5164.

    The example below is a simplified version for testing. The source connector is a database reader. The Destination connector is a file writer. All transformer steps are in the Source connector. For this example all steps are message builder steps mapping a input field to an output field. The real channel has several message builder steps and javascript steps. Output is an XML file. Datatypes for both source & destination is XML.

    #1 is the simplified outbound message template for this example. Note the xmlns="urn:hl7-org:v3" namespace. Of course with it in place, I get #2 for output with the template plus the addition of the fields I am mapping to appended to the bottom with a blank namespace. Just to test the transformer steps, if I remove the namespace, I get #3 for output (desired output) which has the fields from the database mapped to Given & Family Names, Birthtime and GenderCode. Of course no namespace causes problems down the road.

    Based on a few forum posts I’ve seen, including http://www.mirthcorp.com/community/f...ange+namespace from Daniel Svanstedt, I tried putting default xml namespace = 'urn:hl7-org:v3' in the first transformer step (where I get #4 ie. no data values) and in the preprocessor script (where I get #2 ie. a duplicate structure with no namespace.)

    What am I doing wrong? I expect it is something really simple that I am missing.

    I have unchecked the “strip namespace” option at least on the destination side otherwise I get a “xsi not bound” error.

    Any help/redirection would be really appreciated. I basically have a working channel but I need to get this namespace issue figured out.

    Thanks for your help.

    1. Outbound Message Template:
    <?xml version="1.0"?>
    <?xml-stylesheet type="text/xsl" href="CCD.xsl"?>
    <ClinicalDocument xmlns="urn:hl7-org:v3" xmlns:voc="urn:hl7-org:v3/voc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:hl7-org:v3 C:\DOCUME~1\RICKGE~1\MYDOCU~1\AlschulerAssociates\ projects\hl7\CDA_R2_NormativeWebEdition2005\infras tructure\cda\CDA.xsd">
    <recordTarget>
    <patientRole>
    <patient>
    <name>
    <given>Henry</given>
    <family>Levin</family>
    <suffix>the 7th</suffix>
    </name>
    <administrativeGenderCode code="M" codeSystem="2.16.840.1.113883.5.1"/>
    <birthTime value="19320924"/>
    </patient>
    </patientRole>
    </recordTarget>
    </ClinicalDocument>

    2. Output with xmlns="urn:hl7-org:v3"
    <ClinicalDocument xmlns="urn:hl7-org:v3" xmlns:voc="urn:hl7-org:v3/voc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:hl7-org:v3 C:\DOCUME~1\RICKGE~1\MYDOCU~1\AlschulerAssociates\ projects\hl7\CDA_R2_NormativeWebEdition2005\infras tructure\cda\CDA.xsd">
    <recordTarget>
    <patientRole>
    <patient>
    <name>
    <given>Henry</given>
    <family>Levin</family>
    <suffix>the 7th</suffix>
    </name>
    <administrativeGenderCode code="M" codeSystem="2.16.840.1.113883.5.1"/>
    <birthTime value="19320924"/>
    </patient>
    </patientRole>
    </recordTarget>
    <recordTarget xmlns="">
    <patientRole>
    <patient>
    <name>
    <family>Jones</family>
    <given>Mark</given>
    </name>
    <birthTime value="1954-06-18 00:00:00.0"/>
    <administrativeGenderCode code="M"/>
    </patient>
    </patientRole>
    </recordTarget>
    </ClinicalDocument>

    3. Output without xmlns="urn:hl7-org:v3"
    <ClinicalDocument xmlns:voc="urn:hl7-org:v3/voc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:hl7-org:v3 C:\DOCUME~1\RICKGE~1\MYDOCU~1\AlschulerAssociates\ projects\hl7\CDA_R2_NormativeWebEdition2005\infras tructure\cda\CDA.xsd">
    <recordTarget>
    <patientRole>
    <patient>
    <name>
    <given>Mark</given>
    <family>Jones</family>
    <suffix>the 7th</suffix>
    </name>
    <administrativeGenderCode code="M" codeSystem="2.16.840.1.113883.5.1"/>
    <birthTime value="1954-06-18 00:00:00.0"/>
    </patient>
    </patientRole>
    </recordTarget>
    </ClinicalDocument>

    4. Output with xmlns="urn:hl7-org:v3" and default xml namespace = 'urn:hl7-org:v3' in first transformer step
    <ClinicalDocument xmlns="urn:hl7-org:v3" xmlns:voc="urn:hl7-org:v3/voc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:hl7-org:v3 C:\DOCUME~1\RICKGE~1\MYDOCU~1\AlschulerAssociates\ projects\hl7\CDA_R2_NormativeWebEdition2005\infras tructure\cda\CDA.xsd">
    <recordTarget>
    <patientRole>
    <patient>
    <name>
    <given/>
    <family/>
    <suffix>the 7th</suffix>
    </name>
    <administrativeGenderCode code="" codeSystem="2.16.840.1.113883.5.1"/>
    <birthTime value=""/>
    </patient>
    </patientRole>
    </recordTarget>
    </ClinicalDocument>

  • #2
    I figured this much out this weekend after a lot more trial and error. The inbound XML has a blank namespace and I haven't found a way to change it to match the default nameaspace of the outbound. So at this point I am taking the tact of moving the data from the inbound to mapped variables, changing the default namespace to match the outbound:

    default xml namespace = "urn:hl7-org:v3";

    Then move the mapped varibles to the outbound XML.

    If anybody has a better idea, I would like to here it.

    Thanks.

    Comment


    • #3
      Hi, I'm facing the same issue. Can you please explain how you set the default xml namespace to urn:hl7-org:v3 for the inbound mapped variables? I'm just stuck at this point!

      Comment


      • #4
        Actually I didn't figure anything out for the inbound variables. I mapped everything I need to reference from the inbound to connector varibles. I then had a Javascript step containing:

        default xml namespace = "urn:hl7-org:v3";

        Then I started building the outbound message.

        Because of the conflict of namespaces between the inbound (with no namespace) and the outbound with urn:hl7-org:v3 default namespace, I could not directly map data from the inbound tree to the outbound tree. Nor could I reference the inbound and outbound messages at the same time in javascript steps. I had to save the inbound data, then write the outbound.

        Hope that helps some. Let me know if you still have questions.

        Comment


        • #5
          If you don't want to mess with the default namespace you can declare your namespaces and use them:
          Code:
          var hl7v3= new Namespace('urn:hl7-org:v3');
          var firstname = msg.hl7v3::ClinicalDocument.hl7v3::recordTarget.hl7v3::patientRole.hl7v3::patient.hl7v3::name.hl7v3::given.toString();
          Hope that helps.
          Daniel Svanstedt
          Software Engineer
          Mirth Corporation

          Want professional services, support, and enterprise or virtual appliances? It's all available from the Mirth Corporation:
          Mirth Support | Mirth Training | Mirth Appliances | Online Training | Developer Q&A

          Don't forget, Mirth Support gives you access to all of our online training videos, and silver support gives you access to developer Q&As!

          Comment


          • #6
            I've had a similar problem ever since I started working with MIRTH Connect 2.0 I opted to create 2 destinations. One destination outputs the raw result from the database reader, I've created channel variables in the first destination, which I then use in destination two to output a HL7 v3 template.
            @dans I'm not sure how to use the code you provided,care to add some more explanation.

            Comment


            • #7
              I'm using 3.5.2 and still have issues with namespaces, @dans solution works perfect.

              Comment


              • #8
                It's also mentioned in the tooltip when you use XML as a data type. cross namespace errors are common and usually a pain.
                HL7v2.7 Certified Control Specialist!

                Comment

                Working...
                X