web stats
XML Namespace - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 03-03-2011, 09:09 AM
swjackson swjackson is offline
Mirth Newb
 
Join Date: Jan 2011
Posts: 8
swjackson is on a distinguished road
Default 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>
Reply With Quote
  #2  
Old 03-06-2011, 01:08 PM
swjackson swjackson is offline
Mirth Newb
 
Join Date: Jan 2011
Posts: 8
swjackson is on a distinguished road
Default

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.
Reply With Quote
  #3  
Old 03-09-2011, 07:18 PM
maalaakha maalaakha is offline
What's HL7?
 
Join Date: Mar 2011
Posts: 1
maalaakha is on a distinguished road
Default

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!
Reply With Quote
  #4  
Old 03-11-2011, 07:25 AM
swjackson swjackson is offline
Mirth Newb
 
Join Date: Jan 2011
Posts: 8
swjackson is on a distinguished road
Default

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.
Reply With Quote
  #5  
Old 03-11-2011, 09:53 AM
dans dans is offline
Mirth Employee
 
Join Date: Apr 2007
Location: Irvine, CA
Posts: 590
dans is an unknown quantity at this point
Default

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!
Reply With Quote
  #6  
Old 03-16-2011, 12:55 AM
jwesonga jwesonga is offline
What's HL7?
 
Join Date: Mar 2011
Posts: 1
jwesonga is on a distinguished road
Default

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.
Reply With Quote
  #7  
Old 07-12-2018, 03:52 PM
ppazos ppazos is offline
OBX.2 Kenobi
 
Join Date: May 2008
Posts: 76
ppazos
Default

I'm using 3.5.2 and still have issues with namespaces, @dans solution works perfect.
Reply With Quote
  #8  
Old 07-12-2018, 09:54 PM
siddharth siddharth is offline
Mirth Guru
 
Join Date: Feb 2013
Posts: 832
siddharth is on a distinguished road
Default

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!
Reply With Quote
Reply

Tags
default namespace, namespaces, xml

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -8. The time now is 09:51 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2019, vBulletin Solutions, Inc.
Mirth Corporation