Scripting for XML

Homepage Clovertech Forums Read Only Archives Cloverleaf Cloverleaf Scripting for XML

  • Creator
    Topic
  • #51309
    Scott Jones
    Participant

    Hello All,

    My group is new to use xml and I am in need of some help.

    What I need help with is tcl scripting the same for xml as it would be for HL7?

    All that I want to accomplish is to filter on the physician ID and if it is in the table pass the message otherwise suppress it. If it is allowed to pass it would simple pass as raw.

    CL vs 5.6.1

    AIX platform.

    Any help would be appreciated. Resource for scripting or sample code?

    Thanks,

    Scott

Viewing 9 reply threads
  • Author
    Replies
    • #69630
      David Barr
      Participant

      I’d take a look at http://tclxml.sourceforge.net/

    • #69631
      Troy Morton
      Participant

      This is also a very good source for Parsing and Creating XML with Tcl using the DOM (Document Object Model) extension for Tcl.

      The Tcl Wiki

    • #69632
      Scott Jones
      Participant

      Thanks. I’ll take a look and see what I learn. – Scott

    • #69633
      Richard Hart
      Participant

      Hi Scott.

      I’ve been involved with a few Cloverleaf web services projects, with translations

      from          to

      XML     ->  XML,

      XML     ->  HL7,

      XML     ->  various and

      various->  XML

      I’ve been using the Cloverleaf GRM interface within TCL scripts and that works pretty well.  I’ve written some library for most of the operations (unfortunately unable to share).

      I’ve found that my testing time is a lot longer when working with XML as the document MUST be valid to extract data.  I’m working with multiple ‘imports’ so management of the XML files can also be tricky!

      In my scripts, I’ll validate all the schemas I intend to use at startup.

      eg

                         #

                         # Verify that the XML schemas exits prior to using them

                         #

                     lappend mySchemaList {GDS-Document      StoreDocument_output}

                                         {GDS-Document       SubmitWorkFlowStatus_output}

                                         {GDS-Document       VoidDocument_output}

                                         {HCAL-Message-Core  HcalFault_soap}

                                         {HCAL-Message-Core  Fault_soap}

                     CheckSchema GlobGCDA$HciConnName $mySchemaList

      When grabbing elements from an instantiated message, I set a ‘pointer’ and then

                             #

                             # This has a standard structured ‘detail’ so we grab the

                             # elements we are interested in

                             #

                         set myPtr SOAP-ENV:Envelope.SOAP-ENV:Body.SOAP-ENV:Fault.

                         set myFaultCode     [GetElement $myXml ${myPtr}faultcode]

                         set myFaultString   [GetElement $myXml ${myPtr}faultstring]

                         set myFaultActor    [GetElement $myXml ${myPtr}faultactor]

                         set myErrorCode     [GetElement $myXml ${myPtr}detail.core:StandardError.core:errorCode]

                         set myErrorMessage  [GetElement $myXml ${myPtr}detail.core:StandardError.core:message]

      with library code below – note that GetElement2 is does not use the ‘catch’, so an errors are found! ….

      proc GetElement {aGrmHandle aPtr} {

         set myDat {}

         if {[catch {set myDat [grmfetch $aGrmHandle ${aPtr}.#text]}] == 0} {

             set myDat [datget $myDat VALUE]

         }

         return $myDat

      }

      proc GetElement2 {aGrmHandle aPtr} {

         set myDat {}

         set myDat [grmfetch $aGrmHandle ${aPtr}.#text]

         set myDat [datget $myDat VALUE]

         return $myDat

      }

      I hope this helps as bit!

    • #69634
      Scott Jones
      Participant

      Hi Richard,

      Thanks. I appreciate the insight and experience.

      I’m hoping that I don’t have to worry about the schema as the messages will be processed raw on the engine. I just have to filter out based on the physician ID’s. So, my hope is that this should be simple. – Scott

    • #69635
      Charlie Bursell
      Participant

      Unless your XML is pretty complex (like HL7 version 3 UGH!  🙁 ) you can deal with it much easier and faster using regular expressions.

      I have tried the DOM and it is incredibly slow.  GRM would still require a schema.

      Similar to HL7 if you have a priori knowledge of the structure, you can parse it.

      Here is an example script that I present in my Level 3 class

    • #69636
      Scott Jones
      Participant

      Yes! Thought that I was going crazy. This is much more like what my co-workers and I were talking about.

      Thanks Charlie.

      Scott

    • #69637
      Richard Hart
      Participant

      Hi Scott.

      If you can do it with regular expressions, it certainly is easier.  

      When providing web services, you need to provide the schemas so that applications can call the services and make sure all message are valid – which requires the message to be instantiated.

    • #69638
      Corrie Henry
      Participant

      @Charlie.

      Just want to say thanks.  your post containing the sample XML parsing script helped me out immensely.

    • #69639
      Charlie Bursell
      Participant

      That was posted a long time ago. Good to know it has not exceed the shelf life.  😆

Viewing 9 reply threads
  • The forum ‘Cloverleaf’ is closed to new topics and replies.

Forum Statistics

Registered Users
5,127
Forums
28
Topics
9,299
Replies
34,443
Topic Tags
288
Empty Topic Tags
10