SlideShare a Scribd company logo
GENERATION XSD
XSD Schema/C#/Java
Part 3 – AttributeGroups & Attributes
D. Harrison
September 2022
© 2022, David Harrison, All Rights Reserved
TABLE OF
CONTENTS
Introduction.............................................................................1
The AttributeGroup...................................................................1
Handling Enumerations .............................................................4
Handling AttributeGroup Content................................................8
Remarks ............................................................................... 19
Appendix: Class Documentation ............................................... 20
NegotiatedFareAttributes ...................................................20
DirectAndStopsGroup ........................................................29
DiscountPricingGroup ........................................................37
Appendix: Unit Tests............................................................... 49
NegotiatedFareAttributes ...................................................49
DirectAndStopsGroup ........................................................51
DiscountPricingGroup ........................................................52
Appendix: Base Class Documentation ....................................... 54
W3cAttribute....................................................................54
W3cAttributeGroup ...........................................................68
INTRODUCTION
In the previous article in this series, we looked at the SimpleType and its related
XSD elements W3C Primitives and type restrictions.
In this article we will look in detail at the Attribute (xs:attribute) and
AttributeGroup (xs:AttributeGroup).
We will use the same Schema set as in the previous article, the second version of
Open Travel (www.opentravel.org) for the year 2014 – 2014B.
THE ATTRIBUTEGROUP
The W3C AttributeGroup has the general definition:
<attributeGroup
id=ID
name=NCName
ref=QName
any attributes>
(annotation?),((attribute|attributeGroup)*,anyAttribute?))
</attributeGroup>
So, using Open Travel as our example Schema set, we see such definitions as:
<xs:attributeGroup name="NegotiatedFareAttributes">
<xs:annotation>
<xs:documentation xml:lang="en">Attribute collection providing negotiated fare
profile.</xs:documentation>
</xs:annotation>
<xs:attribute name="NegotiatedFareInd" type="xs:boolean" use="optional">
<xs:annotation>
<xs:documentation xml:lang="en">If true, this is a negotiated fare.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="NegotiatedFareCode" type="xs:string" use="optional">
<xs:annotation>
<xs:documentation xml:lang="en">A code used to identify the negotiated
fare.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="ATPCO_NegCategoryCode" type="xs:string" use="optional">
<xs:annotation>
<xs:documentation xml:lang="en">The ATPCO category code for this negotiated
fare.</xs:documentation>
</xs:annotation>
</xs:attribute>
</xs:attributeGroup>
where the attribute group, NegotiatedFareAttributes, is a collection of xs:attribute
elements with no content but with base types from the W3c Primitive set, e.g.
xs:boolean and xs:string. These we encountered in the previous article.
2
Additionally, we see such definitions as:
<xs:attributeGroup name="DirectAndStopsGroup">
<xs:annotation>
<xs:documentation xml:lang="en">Attribute collection providing information on direct flight
categorization and the number of stops made.</xs:documentation>
</xs:annotation>
<xs:attribute name="DirectFlightsOnly" type="xs:boolean" use="optional">
<xs:annotation>
<xs:documentation xml:lang="en">Indicates the same flight number on the same airline
regardless of number of stops in most cases.</xs:documentation>
<xs:documentation xml:lang="en">
<LegacyDefaultValue>false</LegacyDefaultValue>
</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="NumberStops" use="optional">
<xs:annotation>
<xs:documentation xml:lang="en"> Information regarding the number of stops made.
</xs:documentation>
</xs:annotation>
<xs:simpleType>
<xs:restriction base="xs:nonNegativeInteger">
<xs:maxInclusive value="9"/>
<xs:minInclusive value="0"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:attributeGroup>
Where the xs:attribute collection represented in this definition comprises one with
no content, DirectFlightsOnly, and one specified by a SimpleType with a min/max
restriction and a base type represented by the W3c Primitive numeric type,
xs:nonNegativeInteger.
We also find, in the Open Travel set, an AttributeGroup definition as:
<xs:attributeGroup name="DiscountPricingGroup">
<xs:annotation>
<xs:documentation xml:lang="en">The information needed for applying a discount to a fare.
</xs:documentation>
</xs:annotation>
<xs:attribute name="Purpose" use="optional">
<xs:annotation>
<xs:documentation xml:lang="en">Used to specify the purpose of the discount pricing.
</xs:documentation>
</xs:annotation>
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="Airline">
<xs:annotation>
<xs:documentation xml:lang="en">The discount pricing is from the airline.
</xs:documentation>
</xs:annotation>
</xs:enumeration>
<xs:enumeration value="Custom">
<xs:annotation>
<xs:documentation xml:lang="en">The discount pricing is a custom discount.
</xs:documentation>
</xs:annotation>
</xs:enumeration>
</xs:restriction>
</xs:simpleType>
3
</xs:attribute>
<xs:attribute name="Type" use="optional">
<xs:annotation>
<xs:documentation xml:lang="en">Specifies the type of amount being sent.
</xs:documentation>
</xs:annotation>
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="Amount">
<xs:annotation>
<xs:documentation xml:lang="en">The discount is an amount.</xs:documentation>
</xs:annotation>
</xs:enumeration>
<xs:enumeration value="Percent">
<xs:annotation>
<xs:documentation xml:lang="en">The discount is a percentage.</xs:documentation>
</xs:annotation>
</xs:enumeration>
<xs:enumeration value="PlusUpAmount">
<xs:annotation>
<xs:documentation xml:lang="en">A discount on an international fare that is not
a stored fare.
</xs:documentation>
</xs:annotation>
</xs:enumeration>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attribute name="Usage" use="optional">
<xs:annotation>
<xs:documentation xml:lang="en">Used to specify how the discount is to be applied.
</xs:documentation>
</xs:annotation>
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="Plus">
<xs:annotation>
<xs:documentation xml:lang="en">The discount being applied is an increase to the
fare.
</xs:documentation>
</xs:annotation>
</xs:enumeration>
<xs:enumeration value="Minus">
<xs:annotation>
<xs:documentation xml:lang="en">The discount being applied is subtracted from
the fare.
</xs:documentation>
</xs:annotation>
</xs:enumeration>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attribute name="Discount" type="MoneyOrPercentageType" use="optional">
<xs:annotation>
<xs:documentation xml:lang="en">The monetary amount or percentage of discount that should
be applied.
</xs:documentation>
</xs:annotation>
</xs:attribute>
4
<xs:attribute name="TicketDesignatorCode" type="StringLength1to16" use="optional">
<xs:annotation>
<xs:documentation xml:lang="en">Specifies the code applicable to the fare that is being
discounted.
</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="Text" type="StringLength1to128" use="optional"/>
</xs:attributeGroup>
In this, rather more substantial definition, we see a mix of Attribute styles. As
before, xs:attribute elements with no content, e.g. “Text”, but also ones that have
SimpleType restrictions, such as “Purpose” (enumeration restriction). We also see
ones where the attribute type is a SimpleType which is defined elsewhere in the
Schema set, like “”Discount”, and also where the attribute value is a W3C Primitive
type such as “TicketDesignatorCode” and “Text”.
All these forms need to be embraced in our generator, specifically in the Schema
Studio extension that handles the global AttributeGroup generation process.
HANDLING ENUMERATIONS
If we look at the definition of DiscountPricingGroup we see that there are a number
of SimpleType items based on an enumeration restriction, e.g. “Purpose”, “Type” and
“Usage”. If we take the case of “Type” our generator emits a C# enumeration which
looks like:
5
As can be see the individual enumeration values are transformed from the values
specified in the schema, “Active” and “Custom”, to have an “e” prefix. Why is this?
In the NIEM1 Schema, for example, set we see enumerations that look like:
The values shown here are not consistent with enumeration values in our target
programming languages (C#, Java), so in order to provide a general purpose
transformation, we generate all enumeration values with an “e” prefix, at least.
However, this is not the only challenge when considering enumeration values. We
need to cater for such forms as (again from NIEM):
1
NIEM - Home | NIEM | National Information Exchange Model
6
In this case we need to account for embedded spaces.
In this case we have, not only embedded spaces, but also punctuation characters, in
this case “,”.
7
We also need to take account of cases where the enumeration value starts with the
character “+” or “-“.
Our generator has a Naming Factory designed, among other things, to transform
these enumeration values into forms acceptable to the target development
language.
But, once transformed, how can we know the original value? We must know this
when we come to serialize/deserialize our strong type objects. To enable us to
recover the original form, enumeration values have a custom attribute, which in C#
looks as in the example below, EnumerationFieldBasisAttribute:
The parameter to the custom attribute is the original enumeration value. In
addition, the XML comments also show this original value, which means that the
developer gets to see it via Intellisense (in C#, for example). So, whatever
transformations are applied to the original form we can retrieve the original form via
a method call as exemplified below:
Where the method is an extension to the standard Enum class and takes the form:
8
HANDLING ATTRIBUTEGROUP CONTENT
As we saw in the previous section, AttributeGroup elements can have a variety of
content. The Generator needs to cater for this and emit code that reflects this
landscape of content models.
General
The AttributeGroup classes all have a base class of W3cAttributeGroup, providing the
necessary support.
In terms of content, this base class defines a collection to hold the content items:
One of the constructors that can be used by inheritors causes populates this
collection:
9
The content array parameter contains all W3cAttribute- or W3cAttributeGroup-based
elements defined in the source schema and thus required by the inheritor.
We also need to consider the general need for both a stringified form of the base
class as well as a formatted string which reflects the actual attribute or attribute
group as it would appear in an XML document.
In the W3cAttributeGroup class we have a ToString() method, which looks like this:
In this method, the content of the object, including the type-specific elements in the
content collection, is stringified and returned to the inheritor.
The ToString() method deals with the state of the complete object, which is fine,
but it would be useful to have a representation of the W3cAttributeGroup as it would
10
appear in an XML document, for example. The AttributeGroup() method provides
this service:
In this method the content collection is iterated and each of the elements is handled
in a type-specific way to give the sequence of “name=value” pairs which comprise the
resulting string.
Both the ToString() and AttributeGroup() methods are validated for the various
types, in the Unit Tests presented in a later section.
DirectAndStopsGroup
This attribute group contains two W3cAttribute elements, “DirectFlightsOnly” and
“NumberStops”. To initialise the representation of this class in the DirectAndStops
class, we have a constructor in the form:
11
Here you can see how the individual W3cAttribute elements are instantiated, and
specifically how the restriction information appearing in the source schema enters
the picture, “NumberStops” in particular. The pair of W3cAttribute items are passed
to the base class collection via the call to SetAttributeGroupContent().
The class specific ToString() and AttributeGroup() methods are as shown below:
12
Where the interaction between the inheritor information and that in the base class
can be clearly seen. The AttributeGroup() method looks like:
Here you can see how the base class (W3cAttributeGroup) in this case, since all
content items are based on W3cAttribute, supplies the entire stringified form, i.e.
there are no other content elements.
13
DiscountPricingGroup
In the case of DiscountPricingGroup we have an entirely different situation: all the
items are either SimpleType elements with enumeration restrictions or other
named SimpleType types from our Open Travel schema set. In this case, the
individual items are generated as enumerations directly.
The constructor for this class looks like this:
Notice that base call to the base class method SetAttributeGroupContent() now has
an empty array parameter.
The ToString() method for this case is as shown below:
14
The ToString() method still calls the appropriate base method but since there are
no items being held by the base class collection, the empty string is returned. The
AttributeGroup() method is similar in structure to the form we saw in the previous
15
section. We now have all the items in the inheritor class, DiscountPricingGroup,
appearing in the method to give the special format string:
16
NegotiatedFareAttributes
This class is composed entirely of W3cAttribute items which have distinct restriction
conditions, and this is reflected in the constructor of the class:
Here we can see how the base attribute content collection is populated with the
individual W3cAttribute items.
The ToString() method, in this case, looks as shown below:
17
In the case of the AttributeGroup() method, the following is emitted:
18
Here we see that all the content for the resultant string form comes from the base
method since that is where all the actual content resides.
19
REMARKS
In this article, we have looked at several styles of AttributeGroup classes as emitted
by our generator, all taken from the Open Travel 2014B specification.
The configuration of Schema Studio allows us to specify if the generated classes
should have appropriate methods to serialize/deserialize class instances. The topic
of serialization/deserialization is pended to a later article.
The AttributeGroup/Attribute types generated, are described in the Class
Documentation Appendix below, for which corresponding tests are provided in the
Unit Test Appendix following.
20
APPENDIX: CLASS DOCUMENTATION
One of the key assets for a developer when using a class library is documentation.
This appendix gives an overview of the documentation available from the generated
types we saw in the above sections.
It should be noted that the types we consider here are but a small subset of all the
types that can be generated from the OpenTravel/OTA/V2014B Schema set.
SimpleType Name Content-Type XSD Comment
NegotiatedFareAttributes None Attribute collection providing negotiated
fare profile.
DirectAndStopsGroup None
Restricted-
SimpleType/Min-Max
Attribute collection provides information on
direct flight categorization and the number
of stops made.
DiscountPricingGroup Restricted-
SimpleType/Enumeration
The information needed for applying a
discount to a fare.
NegotiatedFareAttributes
21
Index
Properties
Methods
Events
Operators
22
Properties
23
24
Methods
25
26
27
Events
28
Operators
29
DirectAndStopsGroup
30
Index
Properties
Methods
Events
Operators
31
Properties
32
33
Methods
34
35
Events
36
Operators
37
DiscountPricingGroup
38
Index
Properties
Methods
Events
Operators
Enumerations
Properties
39
40
41
42
43
Methods
44
45
Events
46
Operators
47
Enumerations
48
49
APPENDIX: UNIT TESTS
As part of our generation process, we need to assert that the emitted classes meet
their specification. This we do using unit testing.
In this section, we illustrate the tests applied to the AttributeGroup classes noted in
the previous sections.
Index
NegotiatedFareAttributes
DirectAndStopsGroup
DiscountPricingGroup
NegotiatedFareAttributes
50
51
DirectAndStopsGroup
52
DiscountPricingGroup
53
54
APPENDIX: BASE CLASS DOCUMENTATION
In this section we provide the documentation for the key base classes we have used
in the generated code we have seen in earlier sections, W3cAttribute and
W3cAttributeGroup.
W3cAttribute
55
Index
Properties
Methods
Events
Operators
56
Properties
57
58
59
60
61
62
63
Methods
64
65
66
Events
67
Operators
68
W3cAttributeGroup
69
Index
Properties
Methods
Operators
Properties
70
71
72
Methods
73
74
Operators

More Related Content

Similar to Generation_XSD_Article - Part 3.pdf

Scala 3 by Example - Algebraic Data Types for Domain Driven Design - Part 2
Scala 3 by Example - Algebraic Data Types for Domain Driven Design - Part 2Scala 3 by Example - Algebraic Data Types for Domain Driven Design - Part 2
Scala 3 by Example - Algebraic Data Types for Domain Driven Design - Part 2
Philip Schwarz
 
Angular JS2 Training Session #1
Angular JS2 Training Session #1Angular JS2 Training Session #1
Angular JS2 Training Session #1
Paras Mendiratta
 
Workshop 17: EmberJS parte II
Workshop 17: EmberJS parte IIWorkshop 17: EmberJS parte II
Workshop 17: EmberJS parte II
Visual Engineering
 
DSL - expressive syntax on top of a clean semantic model
DSL - expressive syntax on top of a clean semantic modelDSL - expressive syntax on top of a clean semantic model
DSL - expressive syntax on top of a clean semantic model
Debasish Ghosh
 
LEARN C#
LEARN C#LEARN C#
LEARN C#
adroitinfogen
 
GHC Participant Training
GHC Participant TrainingGHC Participant Training
GHC Participant Training
AidIQ
 
Java script tutorial
Java script tutorialJava script tutorial
Java script tutorial
Doeun KOCH
 
Chapter 3.4
Chapter 3.4Chapter 3.4
Chapter 3.4
sotlsoc
 
Struts 2
Struts 2Struts 2
Struts 2
Lalit Garg
 
Generation_XSD_Article - Part 2.pdf
Generation_XSD_Article - Part 2.pdfGeneration_XSD_Article - Part 2.pdf
Generation_XSD_Article - Part 2.pdf
David Harrison
 
SenchaCon 2016: Handle Real-World Data with Confidence - Fredric Berling
SenchaCon 2016: Handle Real-World Data with Confidence - Fredric Berling SenchaCon 2016: Handle Real-World Data with Confidence - Fredric Berling
SenchaCon 2016: Handle Real-World Data with Confidence - Fredric Berling
Sencha
 
Twig Brief, Tips&Tricks
Twig Brief, Tips&TricksTwig Brief, Tips&Tricks
Twig Brief, Tips&Tricks
Andrei Burian
 
Relevance trilogy may dream be with you! (dec17)
Relevance trilogy  may dream be with you! (dec17)Relevance trilogy  may dream be with you! (dec17)
Relevance trilogy may dream be with you! (dec17)
Woonsan Ko
 
Elastic tire demo
Elastic tire demoElastic tire demo
Elastic tire demo
Scott Hamilton
 
Generation_XSD_Article.docx
Generation_XSD_Article.docxGeneration_XSD_Article.docx
Generation_XSD_Article.docx
David Harrison
 
Javascript sivasoft
Javascript sivasoftJavascript sivasoft
Javascript sivasoft
ch samaram
 
Reversing JavaScript
Reversing JavaScriptReversing JavaScript
Reversing JavaScript
Roberto Suggi Liverani
 
Getting started with ES6
Getting started with ES6Getting started with ES6
Getting started with ES6
Nitay Neeman
 
AEM Sightly Template Language
AEM Sightly Template LanguageAEM Sightly Template Language
AEM Sightly Template Language
Gabriel Walt
 
Processor Refactoring.pdf
Processor Refactoring.pdfProcessor Refactoring.pdf
Processor Refactoring.pdf
David Harrison
 

Similar to Generation_XSD_Article - Part 3.pdf (20)

Scala 3 by Example - Algebraic Data Types for Domain Driven Design - Part 2
Scala 3 by Example - Algebraic Data Types for Domain Driven Design - Part 2Scala 3 by Example - Algebraic Data Types for Domain Driven Design - Part 2
Scala 3 by Example - Algebraic Data Types for Domain Driven Design - Part 2
 
Angular JS2 Training Session #1
Angular JS2 Training Session #1Angular JS2 Training Session #1
Angular JS2 Training Session #1
 
Workshop 17: EmberJS parte II
Workshop 17: EmberJS parte IIWorkshop 17: EmberJS parte II
Workshop 17: EmberJS parte II
 
DSL - expressive syntax on top of a clean semantic model
DSL - expressive syntax on top of a clean semantic modelDSL - expressive syntax on top of a clean semantic model
DSL - expressive syntax on top of a clean semantic model
 
LEARN C#
LEARN C#LEARN C#
LEARN C#
 
GHC Participant Training
GHC Participant TrainingGHC Participant Training
GHC Participant Training
 
Java script tutorial
Java script tutorialJava script tutorial
Java script tutorial
 
Chapter 3.4
Chapter 3.4Chapter 3.4
Chapter 3.4
 
Struts 2
Struts 2Struts 2
Struts 2
 
Generation_XSD_Article - Part 2.pdf
Generation_XSD_Article - Part 2.pdfGeneration_XSD_Article - Part 2.pdf
Generation_XSD_Article - Part 2.pdf
 
SenchaCon 2016: Handle Real-World Data with Confidence - Fredric Berling
SenchaCon 2016: Handle Real-World Data with Confidence - Fredric Berling SenchaCon 2016: Handle Real-World Data with Confidence - Fredric Berling
SenchaCon 2016: Handle Real-World Data with Confidence - Fredric Berling
 
Twig Brief, Tips&Tricks
Twig Brief, Tips&TricksTwig Brief, Tips&Tricks
Twig Brief, Tips&Tricks
 
Relevance trilogy may dream be with you! (dec17)
Relevance trilogy  may dream be with you! (dec17)Relevance trilogy  may dream be with you! (dec17)
Relevance trilogy may dream be with you! (dec17)
 
Elastic tire demo
Elastic tire demoElastic tire demo
Elastic tire demo
 
Generation_XSD_Article.docx
Generation_XSD_Article.docxGeneration_XSD_Article.docx
Generation_XSD_Article.docx
 
Javascript sivasoft
Javascript sivasoftJavascript sivasoft
Javascript sivasoft
 
Reversing JavaScript
Reversing JavaScriptReversing JavaScript
Reversing JavaScript
 
Getting started with ES6
Getting started with ES6Getting started with ES6
Getting started with ES6
 
AEM Sightly Template Language
AEM Sightly Template LanguageAEM Sightly Template Language
AEM Sightly Template Language
 
Processor Refactoring.pdf
Processor Refactoring.pdfProcessor Refactoring.pdf
Processor Refactoring.pdf
 

More from David Harrison

PhoenixRisingArticle.pdf
PhoenixRisingArticle.pdfPhoenixRisingArticle.pdf
PhoenixRisingArticle.pdf
David Harrison
 
IntoTheNebulaArticle.pdf
IntoTheNebulaArticle.pdfIntoTheNebulaArticle.pdf
IntoTheNebulaArticle.pdf
David Harrison
 
PagesToGo.pdf
PagesToGo.pdfPagesToGo.pdf
PagesToGo.pdf
David Harrison
 
IntoTheNebulaArticle.pdf
IntoTheNebulaArticle.pdfIntoTheNebulaArticle.pdf
IntoTheNebulaArticle.pdf
David Harrison
 
PhoenixRisingArticle.pdf
PhoenixRisingArticle.pdfPhoenixRisingArticle.pdf
PhoenixRisingArticle.pdf
David Harrison
 
Test data article
Test data articleTest data article
Test data article
David Harrison
 
Flavours - Classic/Technical BDD
Flavours - Classic/Technical BDDFlavours - Classic/Technical BDD
Flavours - Classic/Technical BDD
David Harrison
 
Babble article - Test Automation & Text Translation
Babble article - Test Automation & Text TranslationBabble article - Test Automation & Text Translation
Babble article - Test Automation & Text Translation
David Harrison
 
Bdd Show and Tell
Bdd Show and TellBdd Show and Tell
Bdd Show and Tell
David Harrison
 
UI Testing Pattern
UI Testing PatternUI Testing Pattern
UI Testing Pattern
David Harrison
 
Soap ui automation
Soap ui automationSoap ui automation
Soap ui automation
David Harrison
 
High sierra part 1
High sierra part 1High sierra part 1
High sierra part 1
David Harrison
 
Selenium Testing @ Agile Speed
Selenium Testing @ Agile SpeedSelenium Testing @ Agile Speed
Selenium Testing @ Agile Speed
David Harrison
 
Workflow Test Automation
Workflow Test AutomationWorkflow Test Automation
Workflow Test Automation
David Harrison
 
Et sensus agile documentation
Et sensus   agile documentationEt sensus   agile documentation
Et sensus agile documentation
David Harrison
 
Web Test Automation
Web Test AutomationWeb Test Automation
Web Test Automation
David Harrison
 

More from David Harrison (16)

PhoenixRisingArticle.pdf
PhoenixRisingArticle.pdfPhoenixRisingArticle.pdf
PhoenixRisingArticle.pdf
 
IntoTheNebulaArticle.pdf
IntoTheNebulaArticle.pdfIntoTheNebulaArticle.pdf
IntoTheNebulaArticle.pdf
 
PagesToGo.pdf
PagesToGo.pdfPagesToGo.pdf
PagesToGo.pdf
 
IntoTheNebulaArticle.pdf
IntoTheNebulaArticle.pdfIntoTheNebulaArticle.pdf
IntoTheNebulaArticle.pdf
 
PhoenixRisingArticle.pdf
PhoenixRisingArticle.pdfPhoenixRisingArticle.pdf
PhoenixRisingArticle.pdf
 
Test data article
Test data articleTest data article
Test data article
 
Flavours - Classic/Technical BDD
Flavours - Classic/Technical BDDFlavours - Classic/Technical BDD
Flavours - Classic/Technical BDD
 
Babble article - Test Automation & Text Translation
Babble article - Test Automation & Text TranslationBabble article - Test Automation & Text Translation
Babble article - Test Automation & Text Translation
 
Bdd Show and Tell
Bdd Show and TellBdd Show and Tell
Bdd Show and Tell
 
UI Testing Pattern
UI Testing PatternUI Testing Pattern
UI Testing Pattern
 
Soap ui automation
Soap ui automationSoap ui automation
Soap ui automation
 
High sierra part 1
High sierra part 1High sierra part 1
High sierra part 1
 
Selenium Testing @ Agile Speed
Selenium Testing @ Agile SpeedSelenium Testing @ Agile Speed
Selenium Testing @ Agile Speed
 
Workflow Test Automation
Workflow Test AutomationWorkflow Test Automation
Workflow Test Automation
 
Et sensus agile documentation
Et sensus   agile documentationEt sensus   agile documentation
Et sensus agile documentation
 
Web Test Automation
Web Test AutomationWeb Test Automation
Web Test Automation
 

Recently uploaded

急速办(bedfordhire毕业证书)英国贝德福特大学毕业证成绩单原版一模一样
急速办(bedfordhire毕业证书)英国贝德福特大学毕业证成绩单原版一模一样急速办(bedfordhire毕业证书)英国贝德福特大学毕业证成绩单原版一模一样
急速办(bedfordhire毕业证书)英国贝德福特大学毕业证成绩单原版一模一样
3ipehhoa
 
7 Best Cloud Hosting Services to Try Out in 2024
7 Best Cloud Hosting Services to Try Out in 20247 Best Cloud Hosting Services to Try Out in 2024
7 Best Cloud Hosting Services to Try Out in 2024
Danica Gill
 
manuaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaal
manuaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaalmanuaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaal
manuaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaal
wolfsoftcompanyco
 
原版仿制(uob毕业证书)英国伯明翰大学毕业证本科学历证书原版一模一样
原版仿制(uob毕业证书)英国伯明翰大学毕业证本科学历证书原版一模一样原版仿制(uob毕业证书)英国伯明翰大学毕业证本科学历证书原版一模一样
原版仿制(uob毕业证书)英国伯明翰大学毕业证本科学历证书原版一模一样
3ipehhoa
 
假文凭国外(Adelaide毕业证)澳大利亚国立大学毕业证成绩单办理
假文凭国外(Adelaide毕业证)澳大利亚国立大学毕业证成绩单办理假文凭国外(Adelaide毕业证)澳大利亚国立大学毕业证成绩单办理
假文凭国外(Adelaide毕业证)澳大利亚国立大学毕业证成绩单办理
cuobya
 
重新申请毕业证书(RMIT毕业证)皇家墨尔本理工大学毕业证成绩单精仿办理
重新申请毕业证书(RMIT毕业证)皇家墨尔本理工大学毕业证成绩单精仿办理重新申请毕业证书(RMIT毕业证)皇家墨尔本理工大学毕业证成绩单精仿办理
重新申请毕业证书(RMIT毕业证)皇家墨尔本理工大学毕业证成绩单精仿办理
vmemo1
 
1比1复刻(bath毕业证书)英国巴斯大学毕业证学位证原版一模一样
1比1复刻(bath毕业证书)英国巴斯大学毕业证学位证原版一模一样1比1复刻(bath毕业证书)英国巴斯大学毕业证学位证原版一模一样
1比1复刻(bath毕业证书)英国巴斯大学毕业证学位证原版一模一样
3ipehhoa
 
Internet of Things in Manufacturing: Revolutionizing Efficiency & Quality | C...
Internet of Things in Manufacturing: Revolutionizing Efficiency & Quality | C...Internet of Things in Manufacturing: Revolutionizing Efficiency & Quality | C...
Internet of Things in Manufacturing: Revolutionizing Efficiency & Quality | C...
CIOWomenMagazine
 
国外证书(Lincoln毕业证)新西兰林肯大学毕业证成绩单不能毕业办理
国外证书(Lincoln毕业证)新西兰林肯大学毕业证成绩单不能毕业办理国外证书(Lincoln毕业证)新西兰林肯大学毕业证成绩单不能毕业办理
国外证书(Lincoln毕业证)新西兰林肯大学毕业证成绩单不能毕业办理
zoowe
 
制作毕业证书(ANU毕业证)莫纳什大学毕业证成绩单官方原版办理
制作毕业证书(ANU毕业证)莫纳什大学毕业证成绩单官方原版办理制作毕业证书(ANU毕业证)莫纳什大学毕业证成绩单官方原版办理
制作毕业证书(ANU毕业证)莫纳什大学毕业证成绩单官方原版办理
cuobya
 
可查真实(Monash毕业证)西澳大学毕业证成绩单退学买
可查真实(Monash毕业证)西澳大学毕业证成绩单退学买可查真实(Monash毕业证)西澳大学毕业证成绩单退学买
可查真实(Monash毕业证)西澳大学毕业证成绩单退学买
cuobya
 
Italy Agriculture Equipment Market Outlook to 2027
Italy Agriculture Equipment Market Outlook to 2027Italy Agriculture Equipment Market Outlook to 2027
Italy Agriculture Equipment Market Outlook to 2027
harveenkaur52
 
[HUN][hackersuli] Red Teaming alapok 2024
[HUN][hackersuli] Red Teaming alapok 2024[HUN][hackersuli] Red Teaming alapok 2024
[HUN][hackersuli] Red Teaming alapok 2024
hackersuli
 
Explore-Insanony: Watch Instagram Stories Secretly
Explore-Insanony: Watch Instagram Stories SecretlyExplore-Insanony: Watch Instagram Stories Secretly
Explore-Insanony: Watch Instagram Stories Secretly
Trending Blogers
 
Understanding User Behavior with Google Analytics.pdf
Understanding User Behavior with Google Analytics.pdfUnderstanding User Behavior with Google Analytics.pdf
Understanding User Behavior with Google Analytics.pdf
SEO Article Boost
 
学位认证网(DU毕业证)迪肯大学毕业证成绩单一比一原版制作
学位认证网(DU毕业证)迪肯大学毕业证成绩单一比一原版制作学位认证网(DU毕业证)迪肯大学毕业证成绩单一比一原版制作
学位认证网(DU毕业证)迪肯大学毕业证成绩单一比一原版制作
zyfovom
 
Gen Z and the marketplaces - let's translate their needs
Gen Z and the marketplaces - let's translate their needsGen Z and the marketplaces - let's translate their needs
Gen Z and the marketplaces - let's translate their needs
Laura Szabó
 
APNIC Foundation, presented by Ellisha Heppner at the PNG DNS Forum 2024
APNIC Foundation, presented by Ellisha Heppner at the PNG DNS Forum 2024APNIC Foundation, presented by Ellisha Heppner at the PNG DNS Forum 2024
APNIC Foundation, presented by Ellisha Heppner at the PNG DNS Forum 2024
APNIC
 
Bài tập unit 1 English in the world.docx
Bài tập unit 1 English in the world.docxBài tập unit 1 English in the world.docx
Bài tập unit 1 English in the world.docx
nhiyenphan2005
 
一比一原版(SLU毕业证)圣路易斯大学毕业证成绩单专业办理
一比一原版(SLU毕业证)圣路易斯大学毕业证成绩单专业办理一比一原版(SLU毕业证)圣路易斯大学毕业证成绩单专业办理
一比一原版(SLU毕业证)圣路易斯大学毕业证成绩单专业办理
keoku
 

Recently uploaded (20)

急速办(bedfordhire毕业证书)英国贝德福特大学毕业证成绩单原版一模一样
急速办(bedfordhire毕业证书)英国贝德福特大学毕业证成绩单原版一模一样急速办(bedfordhire毕业证书)英国贝德福特大学毕业证成绩单原版一模一样
急速办(bedfordhire毕业证书)英国贝德福特大学毕业证成绩单原版一模一样
 
7 Best Cloud Hosting Services to Try Out in 2024
7 Best Cloud Hosting Services to Try Out in 20247 Best Cloud Hosting Services to Try Out in 2024
7 Best Cloud Hosting Services to Try Out in 2024
 
manuaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaal
manuaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaalmanuaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaal
manuaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaal
 
原版仿制(uob毕业证书)英国伯明翰大学毕业证本科学历证书原版一模一样
原版仿制(uob毕业证书)英国伯明翰大学毕业证本科学历证书原版一模一样原版仿制(uob毕业证书)英国伯明翰大学毕业证本科学历证书原版一模一样
原版仿制(uob毕业证书)英国伯明翰大学毕业证本科学历证书原版一模一样
 
假文凭国外(Adelaide毕业证)澳大利亚国立大学毕业证成绩单办理
假文凭国外(Adelaide毕业证)澳大利亚国立大学毕业证成绩单办理假文凭国外(Adelaide毕业证)澳大利亚国立大学毕业证成绩单办理
假文凭国外(Adelaide毕业证)澳大利亚国立大学毕业证成绩单办理
 
重新申请毕业证书(RMIT毕业证)皇家墨尔本理工大学毕业证成绩单精仿办理
重新申请毕业证书(RMIT毕业证)皇家墨尔本理工大学毕业证成绩单精仿办理重新申请毕业证书(RMIT毕业证)皇家墨尔本理工大学毕业证成绩单精仿办理
重新申请毕业证书(RMIT毕业证)皇家墨尔本理工大学毕业证成绩单精仿办理
 
1比1复刻(bath毕业证书)英国巴斯大学毕业证学位证原版一模一样
1比1复刻(bath毕业证书)英国巴斯大学毕业证学位证原版一模一样1比1复刻(bath毕业证书)英国巴斯大学毕业证学位证原版一模一样
1比1复刻(bath毕业证书)英国巴斯大学毕业证学位证原版一模一样
 
Internet of Things in Manufacturing: Revolutionizing Efficiency & Quality | C...
Internet of Things in Manufacturing: Revolutionizing Efficiency & Quality | C...Internet of Things in Manufacturing: Revolutionizing Efficiency & Quality | C...
Internet of Things in Manufacturing: Revolutionizing Efficiency & Quality | C...
 
国外证书(Lincoln毕业证)新西兰林肯大学毕业证成绩单不能毕业办理
国外证书(Lincoln毕业证)新西兰林肯大学毕业证成绩单不能毕业办理国外证书(Lincoln毕业证)新西兰林肯大学毕业证成绩单不能毕业办理
国外证书(Lincoln毕业证)新西兰林肯大学毕业证成绩单不能毕业办理
 
制作毕业证书(ANU毕业证)莫纳什大学毕业证成绩单官方原版办理
制作毕业证书(ANU毕业证)莫纳什大学毕业证成绩单官方原版办理制作毕业证书(ANU毕业证)莫纳什大学毕业证成绩单官方原版办理
制作毕业证书(ANU毕业证)莫纳什大学毕业证成绩单官方原版办理
 
可查真实(Monash毕业证)西澳大学毕业证成绩单退学买
可查真实(Monash毕业证)西澳大学毕业证成绩单退学买可查真实(Monash毕业证)西澳大学毕业证成绩单退学买
可查真实(Monash毕业证)西澳大学毕业证成绩单退学买
 
Italy Agriculture Equipment Market Outlook to 2027
Italy Agriculture Equipment Market Outlook to 2027Italy Agriculture Equipment Market Outlook to 2027
Italy Agriculture Equipment Market Outlook to 2027
 
[HUN][hackersuli] Red Teaming alapok 2024
[HUN][hackersuli] Red Teaming alapok 2024[HUN][hackersuli] Red Teaming alapok 2024
[HUN][hackersuli] Red Teaming alapok 2024
 
Explore-Insanony: Watch Instagram Stories Secretly
Explore-Insanony: Watch Instagram Stories SecretlyExplore-Insanony: Watch Instagram Stories Secretly
Explore-Insanony: Watch Instagram Stories Secretly
 
Understanding User Behavior with Google Analytics.pdf
Understanding User Behavior with Google Analytics.pdfUnderstanding User Behavior with Google Analytics.pdf
Understanding User Behavior with Google Analytics.pdf
 
学位认证网(DU毕业证)迪肯大学毕业证成绩单一比一原版制作
学位认证网(DU毕业证)迪肯大学毕业证成绩单一比一原版制作学位认证网(DU毕业证)迪肯大学毕业证成绩单一比一原版制作
学位认证网(DU毕业证)迪肯大学毕业证成绩单一比一原版制作
 
Gen Z and the marketplaces - let's translate their needs
Gen Z and the marketplaces - let's translate their needsGen Z and the marketplaces - let's translate their needs
Gen Z and the marketplaces - let's translate their needs
 
APNIC Foundation, presented by Ellisha Heppner at the PNG DNS Forum 2024
APNIC Foundation, presented by Ellisha Heppner at the PNG DNS Forum 2024APNIC Foundation, presented by Ellisha Heppner at the PNG DNS Forum 2024
APNIC Foundation, presented by Ellisha Heppner at the PNG DNS Forum 2024
 
Bài tập unit 1 English in the world.docx
Bài tập unit 1 English in the world.docxBài tập unit 1 English in the world.docx
Bài tập unit 1 English in the world.docx
 
一比一原版(SLU毕业证)圣路易斯大学毕业证成绩单专业办理
一比一原版(SLU毕业证)圣路易斯大学毕业证成绩单专业办理一比一原版(SLU毕业证)圣路易斯大学毕业证成绩单专业办理
一比一原版(SLU毕业证)圣路易斯大学毕业证成绩单专业办理
 

Generation_XSD_Article - Part 3.pdf

  • 1. GENERATION XSD XSD Schema/C#/Java Part 3 – AttributeGroups & Attributes D. Harrison September 2022 © 2022, David Harrison, All Rights Reserved
  • 2. TABLE OF CONTENTS Introduction.............................................................................1 The AttributeGroup...................................................................1 Handling Enumerations .............................................................4 Handling AttributeGroup Content................................................8 Remarks ............................................................................... 19 Appendix: Class Documentation ............................................... 20 NegotiatedFareAttributes ...................................................20 DirectAndStopsGroup ........................................................29 DiscountPricingGroup ........................................................37 Appendix: Unit Tests............................................................... 49 NegotiatedFareAttributes ...................................................49 DirectAndStopsGroup ........................................................51 DiscountPricingGroup ........................................................52 Appendix: Base Class Documentation ....................................... 54 W3cAttribute....................................................................54 W3cAttributeGroup ...........................................................68
  • 3. INTRODUCTION In the previous article in this series, we looked at the SimpleType and its related XSD elements W3C Primitives and type restrictions. In this article we will look in detail at the Attribute (xs:attribute) and AttributeGroup (xs:AttributeGroup). We will use the same Schema set as in the previous article, the second version of Open Travel (www.opentravel.org) for the year 2014 – 2014B. THE ATTRIBUTEGROUP The W3C AttributeGroup has the general definition: <attributeGroup id=ID name=NCName ref=QName any attributes> (annotation?),((attribute|attributeGroup)*,anyAttribute?)) </attributeGroup> So, using Open Travel as our example Schema set, we see such definitions as: <xs:attributeGroup name="NegotiatedFareAttributes"> <xs:annotation> <xs:documentation xml:lang="en">Attribute collection providing negotiated fare profile.</xs:documentation> </xs:annotation> <xs:attribute name="NegotiatedFareInd" type="xs:boolean" use="optional"> <xs:annotation> <xs:documentation xml:lang="en">If true, this is a negotiated fare.</xs:documentation> </xs:annotation> </xs:attribute> <xs:attribute name="NegotiatedFareCode" type="xs:string" use="optional"> <xs:annotation> <xs:documentation xml:lang="en">A code used to identify the negotiated fare.</xs:documentation> </xs:annotation> </xs:attribute> <xs:attribute name="ATPCO_NegCategoryCode" type="xs:string" use="optional"> <xs:annotation> <xs:documentation xml:lang="en">The ATPCO category code for this negotiated fare.</xs:documentation> </xs:annotation> </xs:attribute> </xs:attributeGroup> where the attribute group, NegotiatedFareAttributes, is a collection of xs:attribute elements with no content but with base types from the W3c Primitive set, e.g. xs:boolean and xs:string. These we encountered in the previous article.
  • 4. 2 Additionally, we see such definitions as: <xs:attributeGroup name="DirectAndStopsGroup"> <xs:annotation> <xs:documentation xml:lang="en">Attribute collection providing information on direct flight categorization and the number of stops made.</xs:documentation> </xs:annotation> <xs:attribute name="DirectFlightsOnly" type="xs:boolean" use="optional"> <xs:annotation> <xs:documentation xml:lang="en">Indicates the same flight number on the same airline regardless of number of stops in most cases.</xs:documentation> <xs:documentation xml:lang="en"> <LegacyDefaultValue>false</LegacyDefaultValue> </xs:documentation> </xs:annotation> </xs:attribute> <xs:attribute name="NumberStops" use="optional"> <xs:annotation> <xs:documentation xml:lang="en"> Information regarding the number of stops made. </xs:documentation> </xs:annotation> <xs:simpleType> <xs:restriction base="xs:nonNegativeInteger"> <xs:maxInclusive value="9"/> <xs:minInclusive value="0"/> </xs:restriction> </xs:simpleType> </xs:attribute> </xs:attributeGroup> Where the xs:attribute collection represented in this definition comprises one with no content, DirectFlightsOnly, and one specified by a SimpleType with a min/max restriction and a base type represented by the W3c Primitive numeric type, xs:nonNegativeInteger. We also find, in the Open Travel set, an AttributeGroup definition as: <xs:attributeGroup name="DiscountPricingGroup"> <xs:annotation> <xs:documentation xml:lang="en">The information needed for applying a discount to a fare. </xs:documentation> </xs:annotation> <xs:attribute name="Purpose" use="optional"> <xs:annotation> <xs:documentation xml:lang="en">Used to specify the purpose of the discount pricing. </xs:documentation> </xs:annotation> <xs:simpleType> <xs:restriction base="xs:string"> <xs:enumeration value="Airline"> <xs:annotation> <xs:documentation xml:lang="en">The discount pricing is from the airline. </xs:documentation> </xs:annotation> </xs:enumeration> <xs:enumeration value="Custom"> <xs:annotation> <xs:documentation xml:lang="en">The discount pricing is a custom discount. </xs:documentation> </xs:annotation> </xs:enumeration> </xs:restriction> </xs:simpleType>
  • 5. 3 </xs:attribute> <xs:attribute name="Type" use="optional"> <xs:annotation> <xs:documentation xml:lang="en">Specifies the type of amount being sent. </xs:documentation> </xs:annotation> <xs:simpleType> <xs:restriction base="xs:string"> <xs:enumeration value="Amount"> <xs:annotation> <xs:documentation xml:lang="en">The discount is an amount.</xs:documentation> </xs:annotation> </xs:enumeration> <xs:enumeration value="Percent"> <xs:annotation> <xs:documentation xml:lang="en">The discount is a percentage.</xs:documentation> </xs:annotation> </xs:enumeration> <xs:enumeration value="PlusUpAmount"> <xs:annotation> <xs:documentation xml:lang="en">A discount on an international fare that is not a stored fare. </xs:documentation> </xs:annotation> </xs:enumeration> </xs:restriction> </xs:simpleType> </xs:attribute> <xs:attribute name="Usage" use="optional"> <xs:annotation> <xs:documentation xml:lang="en">Used to specify how the discount is to be applied. </xs:documentation> </xs:annotation> <xs:simpleType> <xs:restriction base="xs:string"> <xs:enumeration value="Plus"> <xs:annotation> <xs:documentation xml:lang="en">The discount being applied is an increase to the fare. </xs:documentation> </xs:annotation> </xs:enumeration> <xs:enumeration value="Minus"> <xs:annotation> <xs:documentation xml:lang="en">The discount being applied is subtracted from the fare. </xs:documentation> </xs:annotation> </xs:enumeration> </xs:restriction> </xs:simpleType> </xs:attribute> <xs:attribute name="Discount" type="MoneyOrPercentageType" use="optional"> <xs:annotation> <xs:documentation xml:lang="en">The monetary amount or percentage of discount that should be applied. </xs:documentation> </xs:annotation> </xs:attribute>
  • 6. 4 <xs:attribute name="TicketDesignatorCode" type="StringLength1to16" use="optional"> <xs:annotation> <xs:documentation xml:lang="en">Specifies the code applicable to the fare that is being discounted. </xs:documentation> </xs:annotation> </xs:attribute> <xs:attribute name="Text" type="StringLength1to128" use="optional"/> </xs:attributeGroup> In this, rather more substantial definition, we see a mix of Attribute styles. As before, xs:attribute elements with no content, e.g. “Text”, but also ones that have SimpleType restrictions, such as “Purpose” (enumeration restriction). We also see ones where the attribute type is a SimpleType which is defined elsewhere in the Schema set, like “”Discount”, and also where the attribute value is a W3C Primitive type such as “TicketDesignatorCode” and “Text”. All these forms need to be embraced in our generator, specifically in the Schema Studio extension that handles the global AttributeGroup generation process. HANDLING ENUMERATIONS If we look at the definition of DiscountPricingGroup we see that there are a number of SimpleType items based on an enumeration restriction, e.g. “Purpose”, “Type” and “Usage”. If we take the case of “Type” our generator emits a C# enumeration which looks like:
  • 7. 5 As can be see the individual enumeration values are transformed from the values specified in the schema, “Active” and “Custom”, to have an “e” prefix. Why is this? In the NIEM1 Schema, for example, set we see enumerations that look like: The values shown here are not consistent with enumeration values in our target programming languages (C#, Java), so in order to provide a general purpose transformation, we generate all enumeration values with an “e” prefix, at least. However, this is not the only challenge when considering enumeration values. We need to cater for such forms as (again from NIEM): 1 NIEM - Home | NIEM | National Information Exchange Model
  • 8. 6 In this case we need to account for embedded spaces. In this case we have, not only embedded spaces, but also punctuation characters, in this case “,”.
  • 9. 7 We also need to take account of cases where the enumeration value starts with the character “+” or “-“. Our generator has a Naming Factory designed, among other things, to transform these enumeration values into forms acceptable to the target development language. But, once transformed, how can we know the original value? We must know this when we come to serialize/deserialize our strong type objects. To enable us to recover the original form, enumeration values have a custom attribute, which in C# looks as in the example below, EnumerationFieldBasisAttribute: The parameter to the custom attribute is the original enumeration value. In addition, the XML comments also show this original value, which means that the developer gets to see it via Intellisense (in C#, for example). So, whatever transformations are applied to the original form we can retrieve the original form via a method call as exemplified below: Where the method is an extension to the standard Enum class and takes the form:
  • 10. 8 HANDLING ATTRIBUTEGROUP CONTENT As we saw in the previous section, AttributeGroup elements can have a variety of content. The Generator needs to cater for this and emit code that reflects this landscape of content models. General The AttributeGroup classes all have a base class of W3cAttributeGroup, providing the necessary support. In terms of content, this base class defines a collection to hold the content items: One of the constructors that can be used by inheritors causes populates this collection:
  • 11. 9 The content array parameter contains all W3cAttribute- or W3cAttributeGroup-based elements defined in the source schema and thus required by the inheritor. We also need to consider the general need for both a stringified form of the base class as well as a formatted string which reflects the actual attribute or attribute group as it would appear in an XML document. In the W3cAttributeGroup class we have a ToString() method, which looks like this: In this method, the content of the object, including the type-specific elements in the content collection, is stringified and returned to the inheritor. The ToString() method deals with the state of the complete object, which is fine, but it would be useful to have a representation of the W3cAttributeGroup as it would
  • 12. 10 appear in an XML document, for example. The AttributeGroup() method provides this service: In this method the content collection is iterated and each of the elements is handled in a type-specific way to give the sequence of “name=value” pairs which comprise the resulting string. Both the ToString() and AttributeGroup() methods are validated for the various types, in the Unit Tests presented in a later section. DirectAndStopsGroup This attribute group contains two W3cAttribute elements, “DirectFlightsOnly” and “NumberStops”. To initialise the representation of this class in the DirectAndStops class, we have a constructor in the form:
  • 13. 11 Here you can see how the individual W3cAttribute elements are instantiated, and specifically how the restriction information appearing in the source schema enters the picture, “NumberStops” in particular. The pair of W3cAttribute items are passed to the base class collection via the call to SetAttributeGroupContent(). The class specific ToString() and AttributeGroup() methods are as shown below:
  • 14. 12 Where the interaction between the inheritor information and that in the base class can be clearly seen. The AttributeGroup() method looks like: Here you can see how the base class (W3cAttributeGroup) in this case, since all content items are based on W3cAttribute, supplies the entire stringified form, i.e. there are no other content elements.
  • 15. 13 DiscountPricingGroup In the case of DiscountPricingGroup we have an entirely different situation: all the items are either SimpleType elements with enumeration restrictions or other named SimpleType types from our Open Travel schema set. In this case, the individual items are generated as enumerations directly. The constructor for this class looks like this: Notice that base call to the base class method SetAttributeGroupContent() now has an empty array parameter. The ToString() method for this case is as shown below:
  • 16. 14 The ToString() method still calls the appropriate base method but since there are no items being held by the base class collection, the empty string is returned. The AttributeGroup() method is similar in structure to the form we saw in the previous
  • 17. 15 section. We now have all the items in the inheritor class, DiscountPricingGroup, appearing in the method to give the special format string:
  • 18. 16 NegotiatedFareAttributes This class is composed entirely of W3cAttribute items which have distinct restriction conditions, and this is reflected in the constructor of the class: Here we can see how the base attribute content collection is populated with the individual W3cAttribute items. The ToString() method, in this case, looks as shown below:
  • 19. 17 In the case of the AttributeGroup() method, the following is emitted:
  • 20. 18 Here we see that all the content for the resultant string form comes from the base method since that is where all the actual content resides.
  • 21. 19 REMARKS In this article, we have looked at several styles of AttributeGroup classes as emitted by our generator, all taken from the Open Travel 2014B specification. The configuration of Schema Studio allows us to specify if the generated classes should have appropriate methods to serialize/deserialize class instances. The topic of serialization/deserialization is pended to a later article. The AttributeGroup/Attribute types generated, are described in the Class Documentation Appendix below, for which corresponding tests are provided in the Unit Test Appendix following.
  • 22. 20 APPENDIX: CLASS DOCUMENTATION One of the key assets for a developer when using a class library is documentation. This appendix gives an overview of the documentation available from the generated types we saw in the above sections. It should be noted that the types we consider here are but a small subset of all the types that can be generated from the OpenTravel/OTA/V2014B Schema set. SimpleType Name Content-Type XSD Comment NegotiatedFareAttributes None Attribute collection providing negotiated fare profile. DirectAndStopsGroup None Restricted- SimpleType/Min-Max Attribute collection provides information on direct flight categorization and the number of stops made. DiscountPricingGroup Restricted- SimpleType/Enumeration The information needed for applying a discount to a fare. NegotiatedFareAttributes
  • 25. 23
  • 27. 25
  • 28. 26
  • 34. 32
  • 36. 34
  • 41. 39
  • 42. 40
  • 43. 41
  • 44. 42
  • 46. 44
  • 50. 48
  • 51. 49 APPENDIX: UNIT TESTS As part of our generation process, we need to assert that the emitted classes meet their specification. This we do using unit testing. In this section, we illustrate the tests applied to the AttributeGroup classes noted in the previous sections. Index NegotiatedFareAttributes DirectAndStopsGroup DiscountPricingGroup NegotiatedFareAttributes
  • 52. 50
  • 55. 53
  • 56. 54 APPENDIX: BASE CLASS DOCUMENTATION In this section we provide the documentation for the key base classes we have used in the generated code we have seen in earlier sections, W3cAttribute and W3cAttributeGroup. W3cAttribute
  • 59. 57
  • 60. 58
  • 61. 59
  • 62. 60
  • 63. 61
  • 64. 62
  • 66. 64
  • 67. 65
  • 72. 70
  • 73. 71
  • 75. 73