Search This Blog

Mediaflux aterm xvalues: how to handle values contains spaces

For example, I want to loop through the dictionary entries below:
> dictionary.entries.list :dictionary daris:pssd.study.types
    :term "Bone Densitometry (ultrasound)"
    :term "Cardiac Electrophysiology"
    :term "Combined Results"
    :term "Computed Radiography"
    :term "Computed Tomography"
    :term "Dose Report"
    :term "Electrocardiography"
    :term "Electron Microscopy"
    :term "General Microscopy"
    :term "Intravascular Optical Coherence Tomography"
    :term "Magnetic Resonance Imaging"
    :term "Mammography"
    :term "Nuclear Medicine"
    :term "Optical Microscopy"
    :term "Positron Emission Tomography"
    :term "Positron Emission Tomography/Computed Tomography"
    :term "Quality Assurance"
    :term "Radio Fluoroscopy"
    :term "Slide Microscopy"
    :term "Ultra Sound"
    :term "Unspecified"
    :term "X-Ray Angiography"
The code below CANNOT parse the values properly, because it uses space as the separator:
foreach term [xvalues term [dictionary.entries.list :dictionary daris:pssd.study.types]] {
    puts $term
}
You need to use a different separator char, TCL split function to rebuild the list:
foreach term [split [xvalues term [dictionary.entries.list :dictionary daris:pssd.study.types] ,] ,] {
    puts $term
}



see also

  • xvalues usage:
    > help xvalues
    == LOCAL COMMAND ==
    Returns the values of an XML element or attribute given an XML path. E.g. 'xvalues   []'. The optional separator (defaults to a space) is used to separate the values.
    

No comments:

Post a Comment