Skip to content
This repository has been archived by the owner on Dec 1, 2023. It is now read-only.

Changes for Issue#1 and Issue #6 #8

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 55 additions & 7 deletions DdiToCogs/ConvertToCogs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,11 @@ public class ConvertToCogs

List<Substitution> substitutions = new List<Substitution>();


// --------------------------------------------------------------------------------
// Issue #6 - Variable added to hold maxoccursstring and minoccursstring for choice
string choiceMaxOccurs = null;
string choiceMinOccurs = null;
// --------------------------------------------------------------------------------
private string ProcessXmlSchemaAnnotation(XmlSchemaAnnotation annotation)
{
if (annotation == null)
Expand Down Expand Up @@ -107,10 +111,18 @@ private void ProcessComplexType(XmlSchemaComplexType complexType, bool isItem)
else
{
// Only adding attributes
// --------------------------------------------------------------------------------
// Issue #1 - Modification added to address issue of empty CSV's in complex types
var attributeProps = GetPropertiesFromAttributes(complexContentExtension.Attributes);
dataType.Properties.AddRange(attributeProps);
//---------------------------------------------------------------------------------
}
var attributeProps = GetPropertiesFromAttributes(complexContentExtension.Attributes);
dataType.Properties.AddRange(attributeProps);

// ------------------------------------------------------------------------------------------------------
// Issue #1 - Removed from code and moved to else above to address issue of empty CSV's in complex types
//var attributeProps = GetPropertiesFromAttributes(complexContentExtension.Attributes);
//dataType.Properties.AddRange(attributeProps);
// ------------------------------------------------------------------------------------------------------

}
else
{
Expand All @@ -121,7 +133,18 @@ private void ProcessComplexType(XmlSchemaComplexType complexType, bool isItem)
{
if(complexType.ContentTypeParticle.GetType().Name == "EmptyParticle")
{
// Only adding attributes
// --------------------------------------------------------------------------------
// Issue #1 - Modification added to address issue of empty CSV's in complex types
if (complexType.Particle != null)
{
var elementProps = GetProperties(complexType.Particle);
dataType.Properties.AddRange(elementProps);
}

var attributeProps = GetPropertiesFromAttributes(complexType.Attributes);
dataType.Properties.AddRange(attributeProps);
// --------------------------------------------------------------------------------
}
else
{
Expand Down Expand Up @@ -379,9 +402,11 @@ private List<Property> GetProperties(XmlSchemaParticle particle)
p.MinCardinality = choice.MinOccursString;
p.MaxCardinality = choice.MaxOccursString;
UpdateCardinality(p);
result.Add(p);
// the following lines are commented to process elements associated with references
//result.Add(p);

return result;
//return result;
// --------------------------------------------------------------------------------

}
else
Expand All @@ -396,18 +421,41 @@ private List<Property> GetProperties(XmlSchemaParticle particle)
else
{
// ValueRepresentation and ValueRepresentationReference + other non pairs
// --------------------------------------------------------------------------------
// Issue #6 - Variable updated with maxoccursstring and minoccursstring for choice
choiceMaxOccurs = choice.MaxOccursString;
choiceMinOccurs = choice.MinOccursString;
// --------------------------------------------------------------------------------
}

}


// added to processes elements contained in choices embedded in choices
List<XmlSchemaChoice> choices = choice.Items.OfType<XmlSchemaChoice>().ToList();
if (choices.Count != 0)
{
foreach (var choiceitem in choices)
{
if (choiceitem is XmlSchemaParticle p)
{
var partialResult = GetProperties(p).ToList();
}

}
}
//--------------------------------------------------------------------------------


foreach (var item in choice.Items)
{
if (item is XmlSchemaParticle p)
{
// ---------------------------------------------------------------------------------------
// Issue #6 - Variable used item maxoccursstring and minoccursstring is null for choice
if (p.MaxOccursString == null) p.MaxOccursString = choiceMaxOccurs;
if (p.MinOccursString == null) p.MinOccursString = choiceMinOccurs;
// ---------------------------------------------------------------------------------------

var partialResult = GetProperties(p);
result.AddRange(partialResult);
}
Expand Down
Binary file not shown.
Binary file not shown.