web stats
Insert a specific namespace element attribute w/out namespace attribute appears - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 11-30-2015, 09:05 AM
jritz jritz is offline
Mirth Newb
 
Join Date: Mar 2012
Posts: 6
jritz is on a distinguished road
Thumbs down Insert a specific namespace element attribute w/out namespace attribute appears

How to insert namespace specific element attribute of xsi:type to an existing XML object without a new element namespace element attribute to appear?

XML BEFORE code:
<value code="55561003" codeSystem="2.16.840.1.113883.6.96" codeSystemName="SNOMED-CT" displayName="Active"/>

Figure A: Current Javascript code

var entryRelationship= new XML('<entry typeCode="DRIV"><observation classCode="OBS" moodCode="EVN"><templateId root="2.16.840.1.113883.10.20.22.4.38"/><id/><code code="ASSERTION" codeSystem= "2.16.840.1.113883.5.4"><originalText></originalText></code><text/><statusCode code="completed"/><effectiveTime nullFlavor="UNK"/><value code="55561003" codeSystem= "2.16.840.1.113883.6.96" codeSystemName= "SNOMED-CT" displayName= "Active"/></observation></entry>');
var xsi= new Namespace('xsi','http://www.w3.org/2001/XMLSchema-instance');
entryRelationship.observation.value.@type= "CD";
entryRelationship.observation.value.@type.setName( 'xsi:type');

XML AFTER code:
<value code="55561003" codeSystem="2.16.840.1.113883.6.96" codeSystemName="SNOMED-CT" displayName="Active" xmlns:xsi="urn:hl7-org:v3" xsi:type="CD"/>

Question: After inserting the value element xsi:type attribute (eg. xsi:type="CD"), how does one code using E4X with JS to suppress the xmlns:xsi namespace specific element attribute (eg. xmlns:xsi="urn:hl7-org:v3") from the XML.

DESIRED XML:
<value code="55561003" codeSystem="2.16.840.1.113883.6.96" codeSystemName="SNOMED-CT" displayName="Active" xsi:type="CD"/>
Reply With Quote
  #2  
Old 12-01-2015, 05:26 AM
bwscheller bwscheller is offline
 
Join Date: Jun 2015
Location: Boise, ID
Posts: 48
bwscheller is on a distinguished road
Default

Hello jritz,

The XML Namespace must be declared at some point in the XML. Typically XML Namespaces are declared on the root element so that they can be utilized at any point in the XML document as they are "inherited" down the XML tree.

Have you tried to declare the XML Namespace on the entry element? It is being attached to the value element as that is the first place that it is referenced.
__________________
Brian Scheller
Mirth Fundamentals Certified 06/15
Mirth Advanced Certified 10/15
Reply With Quote
  #3  
Old 12-01-2015, 11:05 AM
jritz jritz is offline
Mirth Newb
 
Join Date: Mar 2012
Posts: 6
jritz is on a distinguished road
Default

Hi Brian.

The original XML doc contains the following root element with it's defined namespace attributes.

<ClinicalDocument xmlns="urn:hl7-org:v3" xmlns:sdtc="urn:hl7-org:v3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

And I haven't tried to modify the XML Namespace on the entry element (eg. <value xmlns:xsi="urn:hl7-org:v3" code="55561003" codeSystem="2.16.840.1.113883.6.96" codeSystemName="SNOMED-CT" displayName="Active" xsi:type="CD"/>) because I believe the <value> element should be referring to the doc default XML Namespace of xmlns="urn:hl7-org:v3".

Please advise. Thanks.
Reply With Quote
  #4  
Old 12-01-2015, 11:27 AM
jritz jritz is offline
Mirth Newb
 
Join Date: Mar 2012
Posts: 6
jritz is on a distinguished road
Default

Brian.

After re-thinking the namespace usage I noticed in my last response the xmlns:xsi namespace attribute was showing xmlns:xsi="urn:hl7-org:v3" where the correct namespace should have been what I just defined in JS (eg. var xsi= new Namespace('xsi','http://www.w3.org/2001/XMLSchema-instance'). So I moved the XML API addNamespace and setName and instead I used the setNamespace and this worked.

Fig A: Modified E4X with JS for setting the appropriate element attribute namespace to xsi

var xsi= new Namespace('xsi','http://www.w3.org/2001/XMLSchema-instance');
entryRelationship.observation.value.@type= "CD";
//entryRelationship.observation.value.@type.addNames pace(xsi); // commented out
entryRelationship.observation.value.@type.setNames pace(xsi);
//entryRelationship.observation.value.@type.setName( 'xsi:type'); // commented out


Issue resolved. Thank you for your follow-up and time. Cheers.
Reply With Quote
Reply

Tags
attribute, e4x, javascript, namespace, remove

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 08:22 AM.


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