Announcement

Collapse
No announcement yet.

Specifying xsi:nil="true" on XML element

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

  • Specifying xsi:nil="true" on XML element

    I have XML to XML channel and I need to sent null values as null
    (Stripe NameSpace option is unselected)
    So I have inbound template which is below;
    Code:
    <mesaj xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
        <mesajBilgisi>
            <mesajTipi xsi:nil="true"/>
            <olayTipi xsi:nil="true"/>
            <mesajTarihi xsi:nil="true"/>
            <gonderenUygulama xsi:nil="true"/>
            <alanUygulama xsi:nil="true"/>
            <tesisAdi xsi:nil="true"/>
            <kontrolID xsi:nil="true"/>
        </mesajBilgisi>
        <masterBilgi>
            <aktif xsi:nil="true"/>
            <ilacMalzeme xsi:nil="true"/>
        </masterBilgi>
    </mesaj>

    and when I sent a message to channel, in transformation step "xsi:nil="true" properties removed from the message.

    Code:
    <mesaj xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
        <mesajBilgisi>
            <mesajTipi/>
            <olayTipi/>
            <mesajTarihi>20150918044728</mesajTarihi>
            <gonderenUygulama>Mirth</gonderenUygulama>
            <alanUygulama>IYS</alanUygulama>
            <tesisAdi>Tesis1</tesisAdi>
            <kontrolID>CID20150918044728458</kontrolID>
        </mesajBilgisi>
        <masterBilgi>
            <aktif/>
            <ilacMalzeme/>
        </masterBilgi>
    </mesaj>
    I think I missed something..

    Channel attached
    Mirth 3.3
    Java 8.60
    Attached Files

  • #2
    I stucked here and I need your suggestions please.

    Comment


    • #3
      I think the issue is that you're overwriting those nodes, so any attributes are reset. You can add that namespaced attribute back though, like this:

      Code:
      var xsi = new Namespace('xsi', 'http://www.w3.org/2001/XMLSchema-instance');
      tmp['mesajBilgisi']['mesajTipi'][email protected]::nil = 'true';
      Step 1: JAVA CACHE...DID YOU CLEAR ...wait, ding dong the witch is dead?

      Nicholas Rupley
      Work: 949-237-6069
      Always include what Mirth Connect version you're working with. Also include (if applicable) the code you're using and full stacktraces for errors (use CODE tags). Posting your entire channel is helpful as well; make sure to scrub any PHI/passwords first.


      - How do I foo?
      - You just bar.

      Comment


      • #4
        Thank you very much Nick for your reply.

        I added code but now it adds to every element even if element has value. Like;

        Code:
        <mesaj xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:SchemaLocation="file:///C:/sema.xsd" xsi:nil="true">
            <mesajBilgisi>
                <mesajTipi xsi:nil="true"/>
                <olayTipi xsi:nil="true"/>
                <mesajTarihi xsi:nil="true">20150925011504</mesajTarihi>
                <gonderenUygulama xsi:nil="true">Mirth</gonderenUygulama>
                <alanUygulama xsi:nil="true">IYS</alanUygulama>
                <tesisAdi xsi:nil="true">Tesis1</tesisAdi>
                <kontrolID xsi:nil="true">CID20150925011504801</kontrolID>
            </mesajBilgisi>
            <masterBilgi>
                <aktif xsi:nil="true"/>
                <ilacMalzeme xsi:nil="true"/>
            </masterBilgi>
        </mesaj>
        So I added if statement to check the element value is null or not and the result is perfect

        Code:
        var xsi = new Namespace('xsi', 'http://www.w3.org/2001/XMLSchema-instance');
        
        var a = tmp['mesajBilgisi']['mesajTarihi']
        if (a === null) {
        	a = tmp['mesajBilgisi']['mesajTarihi'][email protected]::nil = 'true';
        }
        For now my question is; I should create if statement for every element, like;

        Code:
        var xsi = new Namespace('xsi', 'http://www.w3.org/2001/XMLSchema-instance');
        
        var a = tmp['mesajBilgisi']['olayTipi']
        if (a === null) {
        	a = tmp['mesajBilgisi']['olayTipi'][email protected]::nil = 'true';
        }
        
        var b = tmp['mesajBilgisi']['kontrolID']
        if (b === null) {
        	tmp['mesajBilgisi']['kontrolID'][email protected]::nil = 'true';
        }
        
        var c = tmp['mesajBilgisi']['gonderenUygulama']
        if (c === null) {
        	tmp['mesajBilgisi']['gonderenUygulama'][email protected]::nil = 'true';
        }
        
        var d = tmp['mesajBilgisi']['mesajTarihi']
        if (d === null) {
        	tmp['mesajBilgisi']['mesajTarihi'][email protected]::nil = 'true';
        }
        
        .............................
        ...............
        My JavaScript knowledge is limited. Is there any shortcode to check every element
        Last edited by obsessio; 09-24-2015, 03:20 PM.

        Comment


        • #5
          Any idea for this if condition, how can I check all elements?

          Code:
          var xsi = new Namespace('xsi', 'http://www.w3.org/2001/XMLSchema-instance');
          
          var a = tmp['mesajBilgisi']['olayTipi']
          if (a === null) {
          	a = tmp['mesajBilgisi']['olayTipi'][email protected]::nil = 'true';
          }
          
          var b = tmp['mesajBilgisi']['kontrolID']
          if (b === null) {
          	b = tmp['mesajBilgisi']['kontrolID'][email protected]::nil = 'true';
          }
          
          var c = tmp['mesajBilgisi']['gonderenUygulama']
          if (c === null) {
          	c = tmp['mesajBilgisi']['gonderenUygulama'][email protected]::nil = 'true';
          }
          
          var d = tmp['mesajBilgisi']['mesajTarihi']
          if (d === null) {
          	d = tmp['mesajBilgisi']['mesajTarihi'][email protected]::nil = 'true';
          }
          
          .............................
          ...............
          Last edited by obsessio; 10-15-2015, 12:09 PM.

          Comment

          Working...
          X