Skip to content

Commit 1711abf

Browse files
committed
Add optional "type" attribute to "pointfile" element
This allows specifying that point list should be interpreted as line, angle, curve, or closed curve. xsd file does not constrain the type (the same way as for image, geometry, etc.).
1 parent 91cf2af commit 1711abf

File tree

2 files changed

+38
-4
lines changed

2 files changed

+38
-4
lines changed

ModuleDescriptionParser/ModuleDescription.xsd

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
<xsd:element name="string" type="paramType"/>
3232
<xsd:element name="string-vector" type="paramType"/>
3333
<xsd:element name="point" type="pointType"/>
34-
<xsd:element name="pointfile" type="pointType"/>
34+
<xsd:element name="pointfile" type="typedPointType"/>
3535
<xsd:element name="point-vector" type="pointType"/>
3636
<xsd:element name="region" type="pointType"/>
3737
<xsd:element name="region-vector" type="pointType"/>
@@ -78,15 +78,24 @@
7878
<xsd:attribute name="coordinateSystem">
7979
<xsd:simpleType>
8080
<xsd:restriction base="xsd:string">
81-
<xsd:enumeration value="RAS"/>
82-
<xsd:enumeration value="IJK"/>
81+
<xsd:enumeration value="lps"/>
82+
<xsd:enumeration value="ras"/>
83+
<xsd:enumeration value="ijk"/>
8384
</xsd:restriction>
8485
</xsd:simpleType>
8586
</xsd:attribute>
8687
</xsd:extension>
8788
</xsd:complexContent>
8889
</xsd:complexType>
8990

91+
<xsd:complexType name="typedPointType" >
92+
<xsd:complexContent>
93+
<xsd:extension base="pointType">
94+
<xsd:attribute name="type" type="xsd:string"/>
95+
</xsd:extension>
96+
</xsd:complexContent>
97+
</xsd:complexType>
98+
9099
<xsd:complexType name="enumerationType" >
91100
<xsd:complexContent>
92101
<xsd:extension base="paramType">

ModuleDescriptionParser/ModuleDescriptionParser.cxx

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -545,7 +545,7 @@ startElement(void *userData, const char *element, const char **attrs)
545545

546546
// Parse attribute pairs
547547
parameter->SetCPPType("std::string");
548-
parameter->SetType("scalar");
548+
parameter->SetType("point");
549549
for (int attr=0; attr < (attrCount / 2); attr++)
550550
{
551551
if ((strcmp(attrs[2*attr], "multiple") == 0))
@@ -574,6 +574,31 @@ startElement(void *userData, const char *element, const char **attrs)
574574
return;
575575
}
576576
}
577+
else if ((strcmp(attrs[2*attr], "type") == 0))
578+
{
579+
if ((strcmp(attrs[2*attr+1], "any") == 0) ||
580+
(strcmp(attrs[2*attr+1], "point") == 0) ||
581+
(strcmp(attrs[2*attr+1], "line") == 0) ||
582+
(strcmp(attrs[2*attr+1], "angle") == 0) ||
583+
(strcmp(attrs[2*attr+1], "curve") == 0) ||
584+
(strcmp(attrs[2*attr+1], "closedcurve")) )
585+
{
586+
parameter->SetType(attrs[2*attr+1]);
587+
}
588+
else
589+
{
590+
std::string error("ModuleDescriptionParser Error: \"" + std::string(attrs[2*attr+1]) + "\" is not a valid value for the attribute \"" + "type" + "\". Only \"point\", \"line\" , \"angle\", \"curve\", \"closedcurve\", and \"any\" are accepted.");
591+
if (ps->ErrorDescription.size() == 0)
592+
{
593+
ps->ErrorDescription = error;
594+
ps->ErrorLine = XML_GetCurrentLineNumber(ps->Parser);
595+
ps->Error = true;
596+
}
597+
ps->OpenTags.push(name);
598+
delete parameter;
599+
return;
600+
}
601+
}
577602
else if ((strcmp(attrs[2*attr], "fileExtensions") == 0))
578603
{
579604
parameter->SetFileExtensionsAsString(attrs[2*attr+1]);

0 commit comments

Comments
 (0)