Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
use xml_file_reader, only: fill_param
character(132), pointer :: param_xml(:)     => NULL()
character(132), pointer :: param_xsd(:)     => NULL()
character(132), pointer :: param_default(:) => NULL()
call fill_param( param_xml  ,  param_xsd  ,  param_default , &
                'input.xml' , 'input.xsd' , 'input_default.xml' )

Parsing XML data

The xml2eg interface for parsing data is already completely independent of the IDSs and the CPOs. The Xpath and Konz interfaces for parsing data depend on the IDSs and the CPOs in only one place, in the call to imas_xml_parse  and euitm_xml_parse, respectively. Such calls using an IDS dependent version may read

Code Block
use ids_schemas, only: type_parameters_input
use imas_xml_parser, only: tree, imas_xml_parse
type (type_param), intent(in) :: code_parameters
type(tree) :: parameter_list
call euitm_xml_parse(code_parameters, 0, parameter_list)


The corresponding call in a CPO dependent version is

Code Block
use euitm_schemas, only: type_param
use euitm_xml_parser, only: tree, euitm_xml_parse
type (type_param), intent(in) :: code_parameters
type(tree) :: parameter_list
call euitm_xml_parse(code_parameters, 0, parameter_list)


In XMLLIB 3.0.0 the corresponding call is

Code Block
use xmllib_parser, only: tree, xmllib_parse
character(132), pointer :: param_xml(:)
character(132), pointer :: param_xsd(:)
character(132), pointer :: param_default(:)
type(tree) :: parameter_list
call xmllib_parse(param_xml, param_xsd, param_default, 0, parameter_list)

Examples

The following examples are taken from the directory examples  inside: ssh://git@git.iter.org/lib/xmllib.git.

Example 1 for the xml2eg interface

The file data.xml 

Code Block
<parameters>
  <some_int> 13 </some_int>
  <some_real> 21.00 </some_real>
  <myfamily>
    <dad>
      <age>50</age>
      <name>Steve</name>
    </dad>
    <mum>
      <age>48</age>
      <name>Eve</name>
    </mum>
  </myfamily>
  <anotherfamily>
    <dad>
      <age>30</age>
      <name>Knut</name>
    </dad>
    <mum>
      <age>33</age>
      <name>Anna</name>
    </mum>
  </anotherfamily>
</parameters>

The file data.xsd


Code Block
<?xml version="1.0" encoding="UTF-8"?>
 <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
	   elementFormDefault="qualified">
   <xs:annotation>
     <xs:documentation>Code parameters for Nuclearsim 
                     (nuclear reaction rates for thermal plasmas)</xs:documentation>
   </xs:annotation>
   <xs:element name="parameters">
     <xs:complexType>
       <xs:all>
         <xs:element name="some_int" type="xs:integer"/>
         <xs:element name="some_real" type="xs:float"/>
         <xs:element name="myfamily" type="family"/>
         <xs:element name="anotherfamily" type="family"/>
       </xs:all>
     </xs:complexType>
   </xs:element>
   <xs:complexType name="family">
     <xs:all>
       <xs:element name="dad" type="person"/>
       <xs:element name="mum" type="person"/>
     </xs:all>
   </xs:complexType>
   <xs:complexType name="person">
     <xs:all>
       <xs:element name="age" type="xs:integer"/>
       <xs:element name="name" type="xs:string"/>
     </xs:all>
   </xs:complexType>
 </xs:schema>


The file sample.f90