Rosetta  2020.37
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Types | Public Member Functions | Private Attributes | List of all members
utility::tag::XMLSchemaComplexTypeGenerator Class Reference

The XMLComplexTypeSchemaGenerator is used to define the schema for a complex type as they typically occurr in Rosetta. More...

#include <XMLSchemaGeneration.hh>

Inheritance diagram for utility::tag::XMLSchemaComplexTypeGenerator:
Inheritance graph
[legend]

Public Types

typedef std::function
< std::string(std::string
const &) > 
DerivedNameFunction
 
typedef std::function
< std::string() > 
NameFunction
 

Public Member Functions

 XMLSchemaComplexTypeGenerator ()
 
 ~XMLSchemaComplexTypeGenerator () override
 
 XMLSchemaComplexTypeGenerator (XMLSchemaComplexTypeGenerator const &src)=delete
 
XMLSchemaComplexTypeGeneratoroperator= (XMLSchemaComplexTypeGenerator const &rhs)=delete
 
XMLSchemaComplexTypeGeneratorelement_name (std::string const &)
 
XMLSchemaComplexTypeGeneratordescription (std::string const &)
 Provide the description for this complex type – this is a function that must be called, even if you are passing in an empty string for the description. More...
 
XMLSchemaComplexTypeGeneratorcomplex_type_naming_func (DerivedNameFunction const &naming_function)
 
XMLSchemaComplexTypeGeneratoradd_attribute (XMLSchemaAttribute const &attribute)
 
XMLSchemaComplexTypeGeneratoradd_required_name_attribute (std::string const &desc="")
 
XMLSchemaComplexTypeGeneratoradd_optional_name_attribute (std::string const &desc="")
 
XMLSchemaComplexTypeGeneratoradd_attributes (AttributeList const &attributes)
 
XMLSchemaComplexTypeGeneratorset_subelements_repeatable (XMLSchemaSimpleSubelementList const &subelements, int min_occurs=0, int max_occurs=xsminmax_unbounded)
 set subelements as repeatable (and optional); setting the sub-elements replaces any sub-elements that were previously set. These repeatable subelements are allowed to appear in any order from the point of view of the XML Schema, which is not to say that the order in which they appear cannot matter to the code reading these subelements. This function represents case 2 in the list of behaviors above. More...
 
XMLSchemaComplexTypeGeneratorset_subelements_single_appearance_required (XMLSchemaSimpleSubelementList const &subelements)
 set subelements as single-appearance (and required); setting the sub-elements replaces any sub-elements that were previously set. These single-appearance subelements are allowed to appear in any order from the point of view of the XML Schema, which is not to say that the order in which they appear cannot matter to the code reading these subelements. Due to limitations of XML Schema, if you have a "group" subelement, then it must appear alone; it may not appear with any other group subelements, and it may not appear with other "regular" subelements. This function represents case 3 in the list of behaviors above. More...
 
XMLSchemaComplexTypeGeneratorset_subelements_single_appearance_optional (XMLSchemaSimpleSubelementList const &subelements)
 set subelements as single-appearance (and optional); setting the sub-elements replaces any sub-elements that were previously set. These single-appearance subelements are allowed to appear in any order from the point of view of the XML Schema, which is not to say that the order in which they appear cannot matter to the code reading these subelements. This function represents case 4 in the list of behaviors above. More...
 
XMLSchemaComplexTypeGeneratorset_subelements_pick_one (XMLSchemaSimpleSubelementList const &subelements)
 set the set of subelements with the stipulation that exactly one must be chosen. This function represents case 5 in the list of behaviors above. More...
 
XMLSchemaComplexTypeGeneratorset_subelements_pick_one_or_none (XMLSchemaSimpleSubelementList const &subelements)
 set the set of subelements with the stipulation that one or none should be chosen. This function represents case 6 in the list of behaviors above. More...
 
XMLSchemaComplexTypeGeneratorset_subelements_single_appearance_required_and_ordered (XMLSchemaSimpleSubelementList const &subelements)
 set subelements as single-appearance (and required) with a specified order; setting the sub-elements replaces any sub-elements that were previously set. This function represents case 7 in the list of behaviors above. More...
 
XMLSchemaComplexTypeGeneratoradd_ordered_subelement_set_as_repeatable (XMLSchemaSimpleSubelementList const &subelements)
 Add a subelement list to a growing set of ordered subelements, where elements in this set are labeled as being repeatable. This function corresponds to case 8a in the list of behaviors above and calling it overrides any of the functions for cases 1-7. More...
 
XMLSchemaComplexTypeGeneratoradd_ordered_subelement_set_as_optional (XMLSchemaSimpleSubelementList const &subelements)
 Add a subelement list to a growing set of ordered subelements, where elements in this set are labeled as being optional. There should be only a single element in the input subelement list. This function corresponds to case 8b in the list of behaviors above and calling it overrides any of the functions for cases 1-7. More...
 
XMLSchemaComplexTypeGeneratoradd_ordered_subelement_set_as_required (XMLSchemaSimpleSubelementList const &subelements)
 Add a subelement list to a growing set of ordered subelements, where elements in this set are labeled as being requried. There should be only a single element in the input subelement list. This function corresponds to case 8c in the list of behaviors above and calling it overrides any of the functions for cases 1-7. More...
 
XMLSchemaComplexTypeGeneratoradd_ordered_subelement_set_as_pick_one (XMLSchemaSimpleSubelementList const &subelements)
 Add a subelement list to a growing set of ordered subelements, where elements in this set are labeled as "pick exactly one". There should be more than one element in the input subelement list. This function corresponds to case 8d in the list of behaviors above and calling it overrides any of the functions for cases 1-7. More...
 
XMLSchemaComplexTypeGeneratoradd_ordered_subelement_set_as_pick_one_or_none (XMLSchemaSimpleSubelementList const &subelements)
 Add a subelement list to a growing set of ordered subelements, where elements in this set are labeled as "pick one or none". There should be more than one element in the input subelement list. This function corresponds to case 8e in the list of behaviors above and calling it overrides any of the functions for cases 1-7. More...
 
CTGenSubelementBehavior subelement_behavior () const
 Return what the internal settings of the instance have been set to; this lets one class give another class access to a generator, and then inspect it on a crude level when it gets it back. More...
 
void write_complex_type_to_schema (XMLSchemaDefinition &xsd)
 
- Public Member Functions inherited from utility::VirtualBase
 VirtualBase ()=default
 Default constructor. More...
 
virtual ~VirtualBase ()=default
 The virtual destructor is one of the main reasons for the VirtualBase class. More...
 
 VirtualBase (VirtualBase const &)=default
 
 VirtualBase (VirtualBase &&)=default
 
VirtualBaseoperator= (VirtualBase const &)=default
 
VirtualBaseoperator= (VirtualBase &&)=default
 

Private Attributes

class
XMLSchemaComplexTypeGeneratorImpl
pimpl_
 

Detailed Description

The XMLComplexTypeSchemaGenerator is used to define the schema for a complex type as they typically occurr in Rosetta.

There are seven main categories of complexTypes that regularly appear in Rosetta's XML Schemas, listed in order of most common to least common:

1) complexTypes that contain only attributes, but no subelements

2) complexTypes that contain subelements that can repeat and that need not appear at all e.g. <DsspDesignOperation blueprint="somefile"> <Strand aa="ACDEFGH"> <Helix aa="ACDEFG"> <all append="IKLMNP"> <Helix exclude="P"> </DsspDesignOperation>

(Perhaps a repreat presence of "Helix" could be avoided, but the way DsspDesignOperation works currently, repeat appearances are perfectly legal and sensical).

3) complexTypes that contain subelements that must appear once, where the subelements are allowed to appear in any order,

4) complexTypes that contain subelements that can can appear zero or one times, where the subelements are allowed to appear in any order,

5) complexTypes where one of a set of subelements must be chosen,

6) complexTypes where zero or one of a set of subelements can be chosen,

7) complexTypes where elements must appear in a particular order (which is required if you have two "xs:group" model groups you want both of, as is the case for the OperateOnResidueSubset task operation which can hold both a "residue_selector" group and a "res_lvl_task_op" group), and

8) complexTypes that have ordered sets of subelements where each set is either: a) repeatable, b) optional, c) required, d) pick-one-from-a-list, or e) pick-one-or-none-from-a-list. In these complexTypes, no elements may appear in multiple sets.

For example, it's ok if you want to say "the <Option> subtag is first and it's either there or not, and then afterwards you can have as many <ScoreFunction> and <TaskOperation> tags as you want in any order, and finally, you can put either a single <PackRotamersMover> tag or a <RotamerTrialsMover> tag." This would be like saying that the first set has an <Option> element, and that it is optional, that the second set has both a <ScoreFunction> element and a <TaskOperation> element and the elements of this set are repeatable, and that finally, a third set contains the <PackRotamersMover> element and the <RotamerTrialsMover>, and that neither has to appear but only one of the two may appear, and only once.

However, you cannot say "The <Option> subtag is first, and its either there or not, and then afterwards, you can have as many <ScoreFunction> and <TaskOperation> tags as you want, and then afterwards you may have another <Option> subtag," because then the <Option> tag would appear in two sets (the first and the third). (The reason for this is restriction is to avoid violating the unique particle attribution rule of XML Schema: https://en.wikipedia.org/wiki/Unique_Particle_Attribution )

Clearly XML Schema can support more kinds of elements than the eight that are supported by this class, but these are the ones that seem to appear the most frequently. All functionality provided by this class can also be accomplished using the XMLSchemaComplexType and XMLSchemaElement classes, but would require a deeper understanding of XML Schema. The niche that this class fills is to make it easy for developers to provide XSDs for these most-common case. Adding additional functionality to this class comes at the expense of making it less clear how the class should be used. Write me if you feel that there categories that should be added.

A description must be provided for every complex type even if that description is an empty string; do not forget to provide a description (your code will compile but will not run).

Member Typedef Documentation

typedef std::function< std::string ( std::string const & ) > utility::tag::XMLSchemaComplexTypeGenerator::DerivedNameFunction

Constructor & Destructor Documentation

utility::tag::XMLSchemaComplexTypeGenerator::XMLSchemaComplexTypeGenerator ( )
utility::tag::XMLSchemaComplexTypeGenerator::~XMLSchemaComplexTypeGenerator ( )
override

References pimpl_.

utility::tag::XMLSchemaComplexTypeGenerator::XMLSchemaComplexTypeGenerator ( XMLSchemaComplexTypeGenerator const &  src)
delete

Member Function Documentation

XMLSchemaComplexTypeGenerator & utility::tag::XMLSchemaComplexTypeGenerator::add_attribute ( XMLSchemaAttribute const &  attribute)
XMLSchemaComplexTypeGenerator & utility::tag::XMLSchemaComplexTypeGenerator::add_attributes ( AttributeList const &  attributes)
XMLSchemaComplexTypeGenerator & utility::tag::XMLSchemaComplexTypeGenerator::add_optional_name_attribute ( std::string const &  desc = "")
XMLSchemaComplexTypeGenerator & utility::tag::XMLSchemaComplexTypeGenerator::add_ordered_subelement_set_as_optional ( XMLSchemaSimpleSubelementList const &  subelements)

Add a subelement list to a growing set of ordered subelements, where elements in this set are labeled as being optional. There should be only a single element in the input subelement list. This function corresponds to case 8b in the list of behaviors above and calling it overrides any of the functions for cases 1-7.

References utility::tag::XMLSchemaComplexTypeGeneratorImpl::add_ordered_subelement_set_as_optional(), and pimpl_.

XMLSchemaComplexTypeGenerator & utility::tag::XMLSchemaComplexTypeGenerator::add_ordered_subelement_set_as_pick_one ( XMLSchemaSimpleSubelementList const &  subelements)

Add a subelement list to a growing set of ordered subelements, where elements in this set are labeled as "pick exactly one". There should be more than one element in the input subelement list. This function corresponds to case 8d in the list of behaviors above and calling it overrides any of the functions for cases 1-7.

References utility::tag::XMLSchemaComplexTypeGeneratorImpl::add_ordered_subelement_set_as_pick_one_required(), and pimpl_.

XMLSchemaComplexTypeGenerator & utility::tag::XMLSchemaComplexTypeGenerator::add_ordered_subelement_set_as_pick_one_or_none ( XMLSchemaSimpleSubelementList const &  subelements)

Add a subelement list to a growing set of ordered subelements, where elements in this set are labeled as "pick one or none". There should be more than one element in the input subelement list. This function corresponds to case 8e in the list of behaviors above and calling it overrides any of the functions for cases 1-7.

References utility::tag::XMLSchemaComplexTypeGeneratorImpl::add_ordered_subelement_set_as_pick_one_optional(), and pimpl_.

XMLSchemaComplexTypeGenerator & utility::tag::XMLSchemaComplexTypeGenerator::add_ordered_subelement_set_as_repeatable ( XMLSchemaSimpleSubelementList const &  subelements)

Add a subelement list to a growing set of ordered subelements, where elements in this set are labeled as being repeatable. This function corresponds to case 8a in the list of behaviors above and calling it overrides any of the functions for cases 1-7.

References utility::tag::XMLSchemaComplexTypeGeneratorImpl::add_ordered_subelement_set_as_repeatable(), and pimpl_.

XMLSchemaComplexTypeGenerator & utility::tag::XMLSchemaComplexTypeGenerator::add_ordered_subelement_set_as_required ( XMLSchemaSimpleSubelementList const &  subelements)

Add a subelement list to a growing set of ordered subelements, where elements in this set are labeled as being requried. There should be only a single element in the input subelement list. This function corresponds to case 8c in the list of behaviors above and calling it overrides any of the functions for cases 1-7.

References utility::tag::XMLSchemaComplexTypeGeneratorImpl::add_ordered_subelement_set_as_required(), and pimpl_.

XMLSchemaComplexTypeGenerator & utility::tag::XMLSchemaComplexTypeGenerator::add_required_name_attribute ( std::string const &  desc = "")
XMLSchemaComplexTypeGenerator & utility::tag::XMLSchemaComplexTypeGenerator::complex_type_naming_func ( DerivedNameFunction const &  naming_function)
XMLSchemaComplexTypeGenerator & utility::tag::XMLSchemaComplexTypeGenerator::description ( std::string const &  desc)
XMLSchemaComplexTypeGenerator & utility::tag::XMLSchemaComplexTypeGenerator::element_name ( std::string const &  name)
XMLSchemaComplexTypeGenerator& utility::tag::XMLSchemaComplexTypeGenerator::operator= ( XMLSchemaComplexTypeGenerator const &  rhs)
delete
XMLSchemaComplexTypeGenerator & utility::tag::XMLSchemaComplexTypeGenerator::set_subelements_pick_one ( XMLSchemaSimpleSubelementList const &  subelements)

set the set of subelements with the stipulation that exactly one must be chosen. This function represents case 5 in the list of behaviors above.

References pimpl_, and utility::tag::XMLSchemaComplexTypeGeneratorImpl::set_subelements_pick_one_required().

Referenced by basic::resource_manager::ResourceManager::schema_for_resource_definition_file().

XMLSchemaComplexTypeGenerator & utility::tag::XMLSchemaComplexTypeGenerator::set_subelements_pick_one_or_none ( XMLSchemaSimpleSubelementList const &  subelements)

set the set of subelements with the stipulation that one or none should be chosen. This function represents case 6 in the list of behaviors above.

References pimpl_, and utility::tag::XMLSchemaComplexTypeGeneratorImpl::set_subelements_pick_one_optional().

XMLSchemaComplexTypeGenerator & utility::tag::XMLSchemaComplexTypeGenerator::set_subelements_repeatable ( XMLSchemaSimpleSubelementList const &  subelements,
int  min_occurs = 0,
int  max_occurs = xsminmax_unbounded 
)

set subelements as repeatable (and optional); setting the sub-elements replaces any sub-elements that were previously set. These repeatable subelements are allowed to appear in any order from the point of view of the XML Schema, which is not to say that the order in which they appear cannot matter to the code reading these subelements. This function represents case 2 in the list of behaviors above.

References pimpl_, and utility::tag::XMLSchemaComplexTypeGeneratorImpl::set_subelements_repeatable().

Referenced by utility::tag::XMLSchemaRepeatableCTNode::recursively_write_ct_to_schema(), basic::resource_manager::resource_loader_xsd_type_definition_w_attributes_and_repeatable_subelements(), basic::resource_manager::ResourceManager::schema_for_resource_definition_file(), and basic::resource_manager::locator::xsd_type_definition_w_attributes_and_repeatable_subelements().

XMLSchemaComplexTypeGenerator & utility::tag::XMLSchemaComplexTypeGenerator::set_subelements_single_appearance_optional ( XMLSchemaSimpleSubelementList const &  subelements)

set subelements as single-appearance (and optional); setting the sub-elements replaces any sub-elements that were previously set. These single-appearance subelements are allowed to appear in any order from the point of view of the XML Schema, which is not to say that the order in which they appear cannot matter to the code reading these subelements. This function represents case 4 in the list of behaviors above.

References pimpl_, and utility::tag::XMLSchemaComplexTypeGeneratorImpl::set_subelements_single_appearance_optional().

XMLSchemaComplexTypeGenerator & utility::tag::XMLSchemaComplexTypeGenerator::set_subelements_single_appearance_required ( XMLSchemaSimpleSubelementList const &  subelements)

set subelements as single-appearance (and required); setting the sub-elements replaces any sub-elements that were previously set. These single-appearance subelements are allowed to appear in any order from the point of view of the XML Schema, which is not to say that the order in which they appear cannot matter to the code reading these subelements. Due to limitations of XML Schema, if you have a "group" subelement, then it must appear alone; it may not appear with any other group subelements, and it may not appear with other "regular" subelements. This function represents case 3 in the list of behaviors above.

Why can you not have two or more "group" subelements that are required and whose order is unspecified? Because the folks writing the XML Schema specification decided it would be too difficult for parsers to handle such cases. See the section on "Limitations of unordered content models" on this page: http://docstore.mik.ua/orelly/xml/schema/ch07_04.htm There are two solutions: 1) drop the flexibility that comes with allowing elements to appear in any order and instead specify a rigid order 2) change your format so that the group elements are beneath regular elements, e.g.

<OperateOnResidueSubset> < some residue selector /> < some residue-level-task-operation /> </OperateOnResidueSubset>

would instead become

<OperateOnResidueSubset> <Selector> < some residue selector /> </Selector> <RLTO> < some residue-level-task-operation /> </RLTO> </OperateOnResidueSubset>

which is not as pretty, but would allow order flexibility.

The reason you can get away with having exactly one group subelement in a "single appearance required" call, is because instead of generating an <xs:all> block, the code instead generates an <xs:choice> block. Of course order does not matter when there is only a single subelement.

References pimpl_, and utility::tag::XMLSchemaComplexTypeGeneratorImpl::set_subelements_single_appearance_required().

XMLSchemaComplexTypeGenerator & utility::tag::XMLSchemaComplexTypeGenerator::set_subelements_single_appearance_required_and_ordered ( XMLSchemaSimpleSubelementList const &  subelements)

set subelements as single-appearance (and required) with a specified order; setting the sub-elements replaces any sub-elements that were previously set. This function represents case 7 in the list of behaviors above.

References pimpl_, and utility::tag::XMLSchemaComplexTypeGeneratorImpl::set_subelements_single_appearance_required_and_ordered().

CTGenSubelementBehavior utility::tag::XMLSchemaComplexTypeGenerator::subelement_behavior ( ) const

Return what the internal settings of the instance have been set to; this lets one class give another class access to a generator, and then inspect it on a crude level when it gets it back.

References pimpl_, and utility::tag::XMLSchemaComplexTypeGeneratorImpl::subelement_behavior().

void utility::tag::XMLSchemaComplexTypeGenerator::write_complex_type_to_schema ( XMLSchemaDefinition xsd)

Member Data Documentation

class XMLSchemaComplexTypeGeneratorImpl* utility::tag::XMLSchemaComplexTypeGenerator::pimpl_
private

The documentation for this class was generated from the following files: