Commit 9cfe009c authored by R D Schaffer's avatar R D Schaffer Committed by Graeme Stewart
Browse files

checkreq fixes (XMLCoreParser-00-01-12)

parent 2495f03e
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
#ifndef __XMLCoreParser_hpp__
#define __XMLCoreParser_hpp__
#include <string>
class XMLCoreParser;
namespace CoreParser
{
class DOMNode;
}
class XMLCoreNode
{
public:
XMLCoreNode (CoreParser::DOMNode* node) : m_node (node)
{
}
XMLCoreNode (const XMLCoreNode& other) : m_node (other.m_node)
{
}
operator const CoreParser::DOMNode& () const
{
return (*m_node);
}
CoreParser::DOMNode& get_node () const
{
return (*m_node);
}
private:
CoreParser::DOMNode* m_node;
};
class XMLCoreFactory
{
public:
virtual ~XMLCoreFactory();
void start (XMLCoreParser& parser, const XMLCoreNode& node);
void end (XMLCoreParser& parser, const XMLCoreNode& node);
void comment (XMLCoreParser& parser, const std::string& comment);
virtual void do_start (XMLCoreParser& parser, const XMLCoreNode& node);
virtual void do_end (XMLCoreParser& parser, const XMLCoreNode& node);
virtual void do_comment (XMLCoreParser& parser, const std::string& comment);
std::string get_name (const XMLCoreNode& node);
int sibling_number (const XMLCoreNode& node);
static int attribute_number (const XMLCoreNode& node);
static bool has_attribute (const XMLCoreNode& node, const std::string& name);
static int get_int (const XMLCoreNode& node, const std::string& name);
static double get_double (const XMLCoreNode& node, const std::string& name);
static bool get_boolean (const XMLCoreNode& node, const std::string& name);
static std::string get_ID (const XMLCoreNode& node, const std::string& name);
static std::string get_value (const XMLCoreNode& node, const std::string& name);
static std::string get_name (const XMLCoreNode& node, int index);
static std::string get_token (const XMLCoreNode& node, const std::string& name);
static bool check_int (const int n, const XMLCoreNode& node, const std::string& name);
static bool check_double (const int n, const XMLCoreNode& node, const std::string& name);
protected:
std::string xmlelementname;
};
class XMLCoreParser
{
public:
XMLCoreParser ();
~XMLCoreParser ();
void set_validation_scheme (const char* parm);
void set_do_namespaces ();
void set_do_schema ();
void set_validation_schema_full_checking ();
void set_create_entity_reference_nodes ();
XMLCoreNode parse (const std::string& file_name);
void visit (const std::string& file_name);
void initialize_factories ();
void register_factory (const std::string& name, XMLCoreFactory* factory);
void register_default_factory (XMLCoreFactory* factory);
void register_external_entity (const std::string& name, const std::string& file_name);
void register_text_entity (const std::string& name, const std::string& text);
static void debug_test (XMLCoreParser& parser, XMLCoreFactory* factory = 0);
private:
void visit (const XMLCoreNode& node);
void terminate ();
};
#endif
package XMLCoreParser
author Christian Arnault <arnault@lal.in2p3.fr>
use AtlasPolicy AtlasPolicy-*
library XMLCoreParser XMLCoreParser.cxx DOMNode.cxx ExpatCoreParser.cxx
apply_pattern installed_library
private
use AtlasExpat AtlasExpat-* External
ignore_pattern config
macro check_args "../data/ATLAS_AGDD.xml"
macro example1_check_args "$(check_args)"
macro example1_dependencies XMLCoreParser
application example1 -check -s=../doc example1.cxx
macro example2_check_args "$(check_args)"
macro example2_dependencies XMLCoreParser
application example2 -check -s=../doc example2.cxx
#macro example3_check_args "$(check_args)"
#macro example3_dependencies XMLCoreParser
#application example3 -check -s=../doc example3.cxx
macro example4_dependencies XMLCoreParser
application example4 -s=../doc example4.cxx
path_prepend XMLPATH "../data"
macro texpatlinkopts "" WIN32 " $(cmt_installarea_linkopts) $(Expat_linkopts) "
application texpat texpat.cxx DOMNode.cxx ExpatCoreParser.cxx
macro texpat_dependencies XMLCoreParser
<?xml version="1.0" encoding="UTF-8"?>
<!ENTITY % Materials.dtd SYSTEM "Materials.dtd" >
%Materials.dtd;
<!ENTITY % DTD_constraint 'DTD_version ( v6 ) #REQUIRED'>
<!-- +++++++++++++++++++++++++++++++++++++++++++++++++
Variable management
+++++++++++++++++++++++++++++++++++++++++++++++++ -->
<!ENTITY % vars '( var* | array* | table* )'>
<!ELEMENT var EMPTY>
<!ATTLIST var
name CDATA #REQUIRED
value CDATA #REQUIRED>
<!ELEMENT array EMPTY>
<!ATTLIST array
name CDATA #REQUIRED
values CDATA #REQUIRED>
<!ELEMENT table ( row )* >
<!ATTLIST table
name CDATA #REQUIRED>
<!ELEMENT row EMPTY>
<!ATTLIST row
values CDATA #REQUIRED>
<!-- +++++++++++++++++++++++++++++++++++++++++++++++++
Units
+++++++++++++++++++++++++++++++++++++++++++++++++ -->
<!ENTITY % units 'unit_length ( mm | cm | m ) "mm"
unit_angle ( deg | degree | radian | mrad ) "deg"'>
<!-- +++++++++++++++++++++++++++++++++++++++++++++++++
Parameter management
+++++++++++++++++++++++++++++++++++++++++++++++++ -->
<!ENTITY % single_parameters '( real* | string* | reference* )'>
<!ENTITY % multiple_parameters '( real_array* | string_vector* | reference_vector* )'>
<!ENTITY % parameter_properties 'name CDATA #IMPLIED
comment CDATA #IMPLIED'>
<!ELEMENT real EMPTY>
<!ATTLIST real
%parameter_properties;
value CDATA #REQUIRED
unit ( m | cm | mm |
degree | radian | mrad |
percent | none ) #REQUIRED>
<!ELEMENT string EMPTY>
<!ATTLIST string
%parameter_properties;
value CDATA #REQUIRED>
<!ELEMENT reference EMPTY>
<!ATTLIST reference
%parameter_properties;
value IDREF #REQUIRED>
<!ELEMENT real_array EMPTY >
<!ATTLIST real_array
%parameter_properties;
values CDATA #REQUIRED
unit ( m | cm | mm |
degree | radian | mrad |
percent | none ) #REQUIRED>
<!ELEMENT string_data EMPTY>
<!ATTLIST string_data
value CDATA #REQUIRED>
<!ELEMENT string_vector ( string_data )+ >
<!ATTLIST string_vector
%parameter_properties;>
<!ELEMENT reference_data EMPTY>
<!ATTLIST reference_data
value IDREF #REQUIRED>
<!ELEMENT reference_vector ( reference_data )+ >
<!ATTLIST reference_vector
%parameter_properties;>
<!-- Xerces
-->
<!ENTITY % single_parameter 'real | string | reference'>
<!ENTITY % multiple_parameter 'real_array | string_vector | reference_vector'>
<!ENTITY % parameters_contents '(%single_parameter; | %multiple_parameter;)*' >
<!-- Together
<!ENTITY % parameters_contents '%single_parameters; | %multiple_parameters;' >
-->
<!ELEMENT parameters ( %parameters_contents; ) >
<!ATTLIST parameters
name ID #REQUIRED
type CDATA #REQUIRED>
<!-- +++++++++++++++++++++++++++++++++++++++++++++++++
Identifiers
+++++++++++++++++++++++++++++++++++++++++++++++++ -->
<!ELEMENT identifier EMPTY>
<!ATTLIST identifier field CDATA #REQUIRED
value CDATA "0"
step CDATA "0">
<!-- +++++++++++++++++++++++++++++++++++++++++++++++++
Positioners
Single
Multiple
Relative
+++++++++++++++++++++++++++++++++++++++++++++++++ -->
<!ENTITY % single_positions '( posXYZ* | posRPhiZ* )'>
<!ENTITY % multiple_positions '( mposR* | mposPhi* | mposWedge* | mposX* | mposY* | mposZ* )'>
<!ENTITY % relative_positions '( axisPos* | axisMPos* )'>
<!ENTITY % positions '( %single_positions; | %multiple_positions; )'>
<!ELEMENT volume EMPTY>
<!ATTLIST volume name IDREF #REQUIRED>
<!-- Xerces
-->
<!ENTITY % any_var 'var | array | table'>
<!ENTITY % position_items '(volume | identifier | %any_var;)*'>
<!-- Together
<!ENTITY % position_items '( volume* | identifier* | %vars; )'>
-->
<!ENTITY % position_contents '%position_items;'>
<!ENTITY % position_properties 'rot CDATA "0; 0; 0"
S CDATA "0"
%units; '>
<!--
Single positioners
-->
<!ENTITY % single_position_contents '%position_contents;' >
<!ELEMENT posXYZ ( %single_position_contents; ) >
<!ATTLIST posXYZ
X_Y_Z CDATA "0; 0; 0"
%position_properties;>
<!ELEMENT posRPhiZ ( %single_position_contents; ) >
<!ATTLIST posRPhiZ
R_Phi_Z CDATA "0; 0; 0"
impliedRot (true | false) "true"
%position_properties;>
<!--
Multiple positioners
-->
<!ENTITY % multiple_position_properties '%position_properties;'>
<!ENTITY % multiple_position_contents '%position_contents;' >
<!ELEMENT mposR ( %multiple_position_contents; ) >
<!ATTLIST mposR
ncopy CDATA #REQUIRED
R0 CDATA "0"
dR CDATA #REQUIRED
Z_Phi CDATA "0; 0"
%multiple_position_properties;>
<!ELEMENT mposPhi ( %multiple_position_contents; ) >
<!ATTLIST mposPhi
ncopy CDATA #REQUIRED
Phi0 CDATA "0"
dPhi CDATA #IMPLIED
R_Z CDATA "0; 0"
impliedRot (true | false) "true"
%multiple_position_properties;>
<!ELEMENT mposWedge ( %multiple_position_contents; ) >
<!ATTLIST mposWedge
wedge_number CDATA #REQUIRED
R_Z CDATA "0; 0"
Phi0 CDATA "0"
sectors CDATA #REQUIRED
impliedRot (true | false) "true"
%multiple_position_properties;>
<!ELEMENT mposX ( %multiple_position_contents; ) >
<!ATTLIST mposX
ncopy CDATA #REQUIRED
X0 CDATA "0"
dX CDATA #REQUIRED
Y_Z CDATA "0; 0"
%multiple_position_properties;>
<!ELEMENT mposY ( %multiple_position_contents; ) >
<!ATTLIST mposY
ncopy CDATA #REQUIRED
Y0 CDATA "0"
dY CDATA #REQUIRED
Z_X CDATA "0; 0"
%multiple_position_properties;>
<!ELEMENT mposZ ( %multiple_position_contents; ) >
<!ATTLIST mposZ
ncopy CDATA #REQUIRED
Z0 CDATA "0"
dZ CDATA #REQUIRED
R_Phi CDATA "0; 0"
X_Y CDATA "0; 0"
%multiple_position_properties;>
<!--
Relative positioners
-->
<!ENTITY % relative_position_properties 'dX CDATA "0"
dY CDATA "0"
dZ CDATA "0"
rotation CDATA "0"
%units; '>
<!ENTITY % relative_position_contents '%position_contents;' >
<!ELEMENT axisPos ( %relative_position_contents; ) >
<!ATTLIST axisPos
shift CDATA "0"
%relative_position_properties;>
<!ELEMENT axisMPos ( %relative_position_contents; ) >
<!ATTLIST axisMPos
ncopy CDATA #REQUIRED
shift0 CDATA "0"
shift CDATA "0"
%relative_position_properties;>
<!-- +++++++++++++++++++++++++++++++++++++++++++++++++
Volumes
Solids
Composition
Stacks
Boolean volumes
+++++++++++++++++++++++++++++++++++++++++++++++++ -->
<!ENTITY % solids '( box* | trd* | tubs* | cons* | pcon* )'>
<!ENTITY % stacks '( stackX* | stackY* | stackZ* )'>
<!ENTITY % booleans '( union* | intersection* | subtraction* )'>
<!ENTITY % volume_properties 'name ID #REQUIRED
parameters IDREF #IMPLIED'>
<!ENTITY % solid_properties '%volume_properties;
material IDREF #REQUIRED
sensitive ( true | false ) "false"'>
<!ELEMENT box EMPTY >
<!ATTLIST box
X_Y_Z CDATA #REQUIRED
%solid_properties;
%units;>
<!ELEMENT trd EMPTY >
<!ATTLIST trd
Xmp_Ymp_Z CDATA #REQUIRED
inclination CDATA "0; 0"
%solid_properties;
%units;>
<!ELEMENT tubs EMPTY >
<!ATTLIST tubs
Rio_Z CDATA #REQUIRED
profile CDATA "0; 360"
%solid_properties;
%units;>
<!ELEMENT cons EMPTY >
<!ATTLIST cons
Rio1_Rio2_Z CDATA #REQUIRED
profile CDATA "0; 360"
%solid_properties;
%units;>
<!ELEMENT pcon (polyplane+)>
<!ATTLIST pcon
profile CDATA "0; 360"
%solid_properties;
%units;>
<!ELEMENT polyplane EMPTY >
<!ATTLIST polyplane
Rio_Z CDATA #REQUIRED>
<!-- Xerces
-->
<!ENTITY % any_single_position 'posXYZ | posRPhiZ'>
<!ENTITY % any_multiple_position 'mposR | mposPhi | mposWedge | mposX | mposY | mposZ'>
<!ENTITY % any_relative_position 'axisPos | axisMPos'>
<!ENTITY % any_position '%any_single_position; | %any_multiple_position;'>
<!ENTITY % foreach_items '(%any_var; | foreach | %any_position;)+'>
<!-- Together
<!ENTITY % foreaches '( foreach* )'>
<!ENTITY % foreach_items '( %vars; | %foreaches; | %positions; )'>
-->
<!ENTITY % foreach_contents '( %foreach_items; )'>
<!ELEMENT foreach ( %foreach_contents; ) >
<!ATTLIST foreach
index CDATA #REQUIRED
loops CDATA #REQUIRED
begin CDATA "0"
step CDATA "1"
when CDATA #IMPLIED>
<!-- Xerces
-->
<!ENTITY % composition_contents '(%any_var; | foreach | %any_position;)+'>
<!-- Together
<!ENTITY % composition_contents '( %vars; | %foreaches; | %positions; )'>
-->
<!ELEMENT composition ( %composition_contents; ) >
<!ATTLIST composition
envelope IDREF #IMPLIED
%volume_properties;>
<!-- Xerces
-->
<!ENTITY % stack_contents '(axisPos | axisMPos)+ '>
<!-- Together
<!ENTITY % stack_contents '%relative_positions;'>
-->
<!ELEMENT stackX ( %stack_contents; ) >
<!ATTLIST stackX
origin (atStart) "atStart"
%volume_properties;>
<!ELEMENT stackY ( %stack_contents; ) >
<!ATTLIST stackY
origin (atStart) "atStart"
%volume_properties;>
<!ELEMENT stackZ ( %stack_contents; ) >
<!ATTLIST stackZ
origin (atStart) "atStart"
%volume_properties;>
<!-- Xerces
-->
<!ENTITY % boolean_contents '( %any_single_position; )+'>
<!-- Together
<!ENTITY % boolean_contents '%single_positions;'>
-->
<!ELEMENT union ( %boolean_contents; ) >
<!ATTLIST union
%volume_properties;>
<!ELEMENT intersection ( %boolean_contents; ) >
<!ATTLIST intersection
%volume_properties;>
<!ELEMENT subtraction ( %boolean_contents; ) >
<!ATTLIST subtraction
%volume_properties;>
<!-- +++++++++++++++++++++++++++++++++++++++++++++++++
Compact
+++++++++++++++++++++++++++++++++++++++++++++++++ -->
<!ENTITY % indet_elements 'dummy_indet'>
<!ENTITY % larg_elements 'dummy_larg'>
<!ENTITY % tile_elements 'dummy_tile'>
<!ENTITY % muon_elements 'dummy_muon'>
<!ELEMENT compact ( %indet_elements; |
%larg_elements; |
%tile_elements; |
%muon_elements; ) >
<!ATTLIST compact
%volume_properties;
envelope IDREF #IMPLIED>
<!-- +++++++++++++++++++++++++++++++++++++++++++++++++
Section
+++++++++++++++++++++++++++++++++++++++++++++++++ -->
<!-- Xerces
-->
<!ENTITY % any_solid 'box | trd | tubs | cons | pcon'>
<!ENTITY % any_stack 'stackX | stackY | stackZ'>
<!ENTITY % any_boolean 'union | intersection | subtraction'>
<!ENTITY % any_volume '%any_solid; | %any_stack; | %any_boolean; | composition'>
<!ENTITY % section_contents '(%any_volume; | compact | parameters | %any_var;)*'>
<!-- Together
<!ENTITY % parameters_s '( parameters* )'>
<!ENTITY % compositions '( composition* )'>
<!ENTITY % compacts '( compact* )'>
<!ENTITY % volumes '( %solids; | %stacks; | %booleans; | composition* | compact* )'>
<!ENTITY % section_contents '( %volumes; | parameters* | %vars; )'>
-->
<!ELEMENT section ( %section_contents; ) >
<!ATTLIST section
name CDATA #REQUIRED
version CDATA #REQUIRED
date CDATA #REQUIRED
author CDATA #REQUIRED
top_volume IDREF #REQUIRED
%DTD_constraint;>
<!-- +++++++++++++++++++++++++++++++++++++++++++++++++
AGDD