Hoping to put a bow on the regex problems
Given multiple struggle sessions and the assistance of ChatGPT, a revision of the XTCE regular expressions can be proposed to address this issue that has been around since XTCE 1.0.
To resolve this, we need to consider that there are "names" in XTCE and then there are references to names. Most references, but not all, can include a "SpaceSystem Path". Parameters and Arguments are a special case of reference in that they can reference parameters of array and aggregate (read C structure) types, which have extensions to their naming that leverage brackets and period characters.
Reference Type |
Structural Form |
Notes |
ArgumentRef |
name + array modifier or aggregate modifier |
arguments are local to MetaCommand elements |
ArgumentTypeRef |
optional path + name |
|
ParameterRef |
optional path + name + array modifier or aggregate modifier |
|
ParameterTypeRef |
optional path + name |
includes typeRef and arrayTypeRef |
|
ReturnParmRef |
optional path + name + array modifier or aggregate modifier |
|
ContainerRef |
optional path + name |
|
StreamRef |
optional path + name |
|
MetaCommandRef |
optional path + name |
|
MessageRef |
optional path + name |
|
ServiceRef |
optional path + name |
|
In the existing XTCE schema, names are restricted by the pattern specified in the complexType "NameType". References are restricted by the pattern specified in the complexType "ReferenceType". Going forward, it will be necessary to replace this with four variants (not including the description of NameType below):
NameType - Captures the names of objects. Defines a basic name where all characters are allowed except '.', '[', ']', ':', '/', and whitespace (previously only space character, whitespace adds tabs to the restriction).
NameReferenceNoPathType - This is identical to NameType above and is used for references that point to named objects for which path is not an option and array/aggregate typing is not an option. This is not used by the schema.
ExpandedNameReferenceNoPathType - Defines a reference to a named object where array and aggregate are possibilities, but path is not a possibility. This is used by the argumentName attribute within the ArgumentAssignment element and ArgumentRef variations.
NameReferenceWithPathType - Defines a reference that can include a path to a named object where array and aggregate are not possible. This is the most common reference. It is used by the ParameterTypeRef, ArgumentTypeRef, baseType attribute, typeRef attribute, arrayTypeRef attribute, spaceSystemAtRisk attribute, scopeToSpaceSystem attribute, triggerContainer attribute, StreamRef, ContainerRef, MetaCommandRef, ServiceRef, and MessageRef variations.
ExpandedNameReferenceWithPathType - Defines a reference that can include a path to a named object where array and aggregate are possible. This is used by the ParameterRef variations.
To begin the actual resolution, we first need to update the existing NameType from:
<simpleType name="NameType">
<annotation>
<documentation>Defines a name where all characters are allowed except '.', '[', ']', ':', ' ', and '/'. See NameDescriptionType.</documentation>
</annotation>
<restriction base="normalizedString">
<pattern value="[^./:\[\] ]+"/>
</restriction>
</simpleType>
revised:
Change Summary: Clarifies and corrects whitespace to include both spaces and tabs.
<simpleType name="NameType">
<annotation>
<documentation>Restricts a basic object name in a document where all characters are allowed except '.', '[', ']', ':', '/', and whitespace. See NameDescriptionType.</documentation>
</annotation>
<restriction base="normalizedString">
<pattern value="[^.\[\]:/ \t]+"/>
</restriction>
</simpleType>
Next step is to remove and replace the simpleType named "NameReferenceType". It is not specific enough.
Content to delete (and replace next):
<simpleType name="NameReferenceType">
<annotation>
<documentation>Describe a reference to a named item in an XTCE instance document. The named must be of schema type NameType. All name references use a Unix style file system name format where the SpaceSystem names form a path in the SpaceSystem tree. The following characters are reserved for the path: '/', '..' and '.' (multiple consecutive '/'s are treated as one). The path portion is similar to the directory path used in file system names and the path characters have similar meaning (e.g., SimpleSat/Bus/EPDS/BatteryOne/Voltage). There are three overall forms for name references: absolute path, relative path and just the name. The first two forms are called qualified name references; the last form is called an unqualified name reference. The unqualified form refers to an item in the SpaceSystem the reference is used in. The unqualified form refers to an item in the SpaceSystem the reference is used in. It is illegal for a name reference to point to no item ("a dangling name reference").</documentation>
</annotation>
<restriction base="normalizedString">
<pattern value="/?(([^./:\[\]]+|\.|\.\.)/)*([^./:\[\]]+)+"/>
</restriction>
</simpleType>
Replace with these 4 simpleType definitions:
<simpleType name="NameReferenceNoPathType">
<annotation>
<documentation xml:lang="en">This is identical to NameType above and is used for references that point to named objects for which path is not an option and array/aggregate typing is not an option. This is not used by the schema.</documentation>
</annotation>
<restriction base="normalizedString">
<pattern value="[^.\[\]:/ \t]+"/>
</restriction>
</simpleType>
<simpleType name="ExpandedNameReferenceNoPathType">
<annotation>
<documentation xml:lang="en">Defines a reference to a named object where array and aggregate are possibilities, but path is not a possibility. This is used by the argumentName attribute within the ArgumentAssignment element and ArgumentRef variations.</documentation>
</annotation>
<restriction base="normalizedString">
<pattern value="([^\.\[\]:/ \t]+(\[[0-9]+\])*(\.[^\.\[\]:/ \t]+(\[[0-9]+\])*)*)"/>
</restriction>
</simpleType>
<simpleType name="NameReferenceWithPathType">
<annotation>
<documentation xml:lang="en">Defines a reference that can include a path to a named object where array and aggregate are not possible. The named must be of schema type NameType. All name references use a Unix style file system name format where the SpaceSystem names form a path in the SpaceSystem tree. The following characters are reserved for the path: '/', '..' and '.' (multiple consecutive '/'s are treated as one). The path portion is similar to the directory path used in file system names and the path characters have similar meaning (e.g., SimpleSat/Bus/EPDS/BatteryOne/Voltage). There are three overall forms for name references: absolute path, relative path and just the name. The first two forms are called qualified name references; the last form is called an unqualified name reference. The unqualified form refers to an item in the SpaceSystem the reference is used in. The unqualified form refers to an item in the SpaceSystem the reference is used in. All name references must resolve to a named item (i.e. no dangling name references). This is used by the ParameterTypeRef, ArgumentTypeRef, baseType attribute, typeRef attribute, arrayTypeRef attribute, spaceSystemAtRisk attribute, scopeToSpaceSystem attribute, triggerContainer attribute, StreamRef, ContainerRef, MetaCommandRef, ServiceRef, and MessageRef variations.</documentation>
</annotation>
<restriction base="normalizedString">
<pattern value="(/?(|\.{1,2}/|[^.\[\]:/ \t]+))*[^.\[\]:/ \t]+"/>
</restriction>
</simpleType>
<simpleType name="ExpandedNameReferenceWithPathType">
<annotation>
<documentation xml:lang="en">Defines a reference that can include a path to a named object where array and aggregate are possible. The named must be of schema type NameType. All name references use a Unix style file system name format where the SpaceSystem names form a path in the SpaceSystem tree. The following characters are reserved for the path: '/', '..' and '.' (multiple consecutive '/'s are treated as one). The path portion is similar to the directory path used in file system names and the path characters have similar meaning (e.g., SimpleSat/Bus/EPDS/BatteryOne/Voltage). There are three overall forms for name references: absolute path, relative path and just the name. The first two forms are called qualified name references; the last form is called an unqualified name reference. The unqualified form refers to an item in the SpaceSystem the reference is used in. The unqualified form refers to an item in the SpaceSystem the reference is used in. All name references must resolve to a named item (i.e. no dangling name references). This is used by the ParameterRef variations.</documentation>
</annotation>
<restriction base="normalizedString">
<pattern value="(/?(|\.{1,2}/|[^.\[\]:/ \t]+))*[^.\[\]:/ \t]+([^\.\[\]:/ \t]+(\[[0-9]+\])*(\.[^\.\[\]:/ \t]+(\[[0-9]+\])*)*)*"/>
</restriction>
</simpleType>
With the above types added, it is then necessary to deploy them to the schema in the places where references are used. Unlike some other resolutions, I will not duplicate entire "simpleType" and "complexType" elements here for context. It is too long. Instead, I will specify the name of the type to be edited and the specific line. In each case, it appears that it would be sufficient for another user to duplicate the work.
In the ArgumentArrayArgumentRefEntryType, change this line from:
<attribute name="argumentRef" type="xtce:NameReferenceType" use="required"/>
to
<attribute name="argumentRef" type="xtce:ExpandedNameReferenceNoPathType" use="required"/>
In the ArgumentArrayParameterRefEntryType, change this line from:
<attribute name="parameterRef" type="xtce:NameReferenceType" use="required"/>
to
<attribute name="parameterRef" type="xtce:ExpandedNameReferenceWithPathType" use="required"/>
In the ArgumentContainerRefEntryType, change this line from:
<attribute name="containerRef" type="xtce:NameReferenceType" use="required"/>
to
<attribute name="containerRef" type="xtce:NameReferenceWithPathType" use="required"/>
In the ArgumentContainerSegmentRefEntryType, change this line from:
<attribute name="containerRef" type="xtce:NameReferenceType" use="required"/>
to
<attribute name="containerRef" type="xtce:NameReferenceWithPathType" use="required"/>
In the ArgumentParameterRefEntryType, change this line from:
<attribute name="parameterRef" type="xtce:NameReferenceType" use="required"/>
to
<attribute name="parameterRef" type="xtce:ExpandedNameReferenceWithPathType" use="required"/>
In the ArgumentParameterSegmentRefEntryType, change this line from:
<attribute name="parameterRef" type="xtce:NameReferenceType" use="required"/>
to
<attribute name="parameterRef" type="xtce:ExpandedNameReferenceWithPathType" use="required"/>
In the ArgumentStreamSegmentEntryType, change this line from:
<attribute name="streamRef" type="xtce:NameReferenceType" use="required"/>
to
<attribute name="streamRef" type="xtce:NameReferenceWithPathType" use="required"/>
In the ArrayParameterRefEntryType, change this line from:
<attribute name="parameterRef" type="xtce:NameReferenceType" use="required"/>
to
<attribute name="parameterRef" type="xtce:ExpandedNameReferenceWithPathType" use="required"/>
In the BaseContainerType, change this line from:
<attribute name="containerRef" type="xtce:NameReferenceType" use="required">
to
<attribute name="containerRef" type="xtce:NameReferenceWithPathType" use="required">
In the ContainerRefType, change this line from:
<attribute name="containerRef" type="xtce:NameReferenceType" use="required">
to
<attribute name="containerRef" type="xtce:NameReferenceWithPathType" use="required">
In the ContainerRefEntryType, change this line from:
<attribute name="containerRef" type="xtce:NameReferenceType" use="required"/>
to
<attribute name="containerRef" type="xtce:NameReferenceWithPathType" use="required"/>
In the ContainerSegmentRefEntryType, change this line from:
<attribute name="containerRef" type="xtce:NameReferenceType" use="required"/>
to
<attribute name="containerRef" type="xtce:NameReferenceWithPathType" use="required"/>
In the MessageRefType, change this line from:
<attribute name="messageRef" type="xtce:NameReferenceType" use="required">
to
<attribute name="messageRef" type="xtce:NameReferenceWithPathType" use="required">
In the ParameterRefEntryType, change this line from:
<attribute name="parameterRef" type="xtce:NameReferenceType" use="required"/>
to
<attribute name="parameterRef" type="xtce:ExpandedNameReferenceWithPathType" use="required"/>
In the ParameterSegmentRefEntryType, change this line from:
<attribute name="parameterRef" type="xtce:NameReferenceType" use="required"/>
to
<attribute name="parameterRef" type="xtce:ExpandedNameReferenceWithPathType" use="required"/>
In the StreamSegmentEntryType, change this line from:
<attribute name="streamRef" type="xtce:NameReferenceType" use="required"/>
to
<attribute name="streamRef" type="xtce:NameReferenceWithPathType" use="required"/>
In the RateInStreamWithStreamNameType, change this line from:
<attribute name="streamRef" type="xtce:NameReferenceType" use="required">
to
<attribute name="streamRef" type="xtce:NameReferenceWithPathType" use="required">
In the ParameterType, change this line from:
<attribute name="parameterTypeRef" type="xtce:NameReferenceType" use="required">
to
<attribute name="parameterTypeRef" type="xtce:NameReferenceWithPathType" use="required">
In the ParameterRefType, change this line from:
<attribute name="parameterRef" type="xtce:NameReferenceType" use="required"/>
to
<attribute name="parameterRef" type="xtce:ExpandedNameReferenceWithPathType" use="required"/>
In the ArgumentAssignmentType, change this line from:
<attribute name="argumentName" type="xtce:NameReferenceType" use="required">
to
<attribute name="argumentName" type="xtce:ExpandedNameReferenceNoPathType" use="required">
In the ArgumentInstanceRefType, change this line from:
<attribute name="argumentRef" type="xtce:NameType" use="required">
to
<attribute name="argumentRef" type="xtce:ExpandedNameReferenceNoPathType" use="required">
In the ArgumentType, change this line from:
<attribute name="argumentTypeRef" type="xtce:NameReferenceType" use="required">
to
<attribute name="argumentTypeRef" type="xtce:NameReferenceWithPathType" use="required">
In the BaseMetaCommandType, change this line from:
<attribute name="metaCommandRef" type="xtce:NameReferenceType" use="required">
to
<attribute name="metaCommandRef" type="xtce:NameReferenceWithPathType" use="required">
In the MetaCommandSetType, change this line from:
<element name="MetaCommandRef" type="xtce:NameReferenceType">
to
<element name="MetaCommandRef" type="xtce:NameReferenceWithPathType">
In the MetaCommandStepType, change this line from:
<attribute name="metaCommandRef" type="xtce:NameReferenceType" use="required"/>
to
<attribute name="metaCommandRef" type="xtce:NameReferenceWithPathType" use="required"/>
In the SignificanceType, change this line from:
<attribute name="spaceSystemAtRisk" type="xtce:NameReferenceType">
to
<attribute name="spaceSystemAtRisk" type="xtce:NameReferenceWithPathType">
In the InterlockType, change this line from:
<attribute name="scopeToSpaceSystem" type="xtce:NameReferenceType">
to
<attribute name="scopeToSpaceSystem" type="xtce:NameReferenceWithPathType">
In the InputOutputTriggerAlgorithmType, change this line from:
<attribute name="triggerContainer" type="xtce:NameReferenceType" use="optional">
to
<attribute name="triggerContainer" type="xtce:NameReferenceWithPathType" use="optional">
In the OnContainerUpdateTriggerType, change this line from:
<attribute name="containerRef" type="xtce:NameReferenceType" use="required">
to
<attribute name="containerRef" type="xtce:NameReferenceWithPathType" use="required">
In the OnParameterUpdateTriggerType, change this line from:
<attribute name="parameterRef" type="xtce:NameReferenceType" use="required">
to
<attribute name="parameterRef" type="xtce:ExpandedNameReferenceWithPathType" use="required">
In the TriggeredMathOperationType, change this line from:
<attribute name="outputParameterRef" type="xtce:NameReferenceType" use="required"/>
to
<attribute name="outputParameterRef" type="xtce:ExpandedNameReferenceWithPathType" use="required"/>
In the CustomStreamType, change these two lines from:
<attribute name="encodedStreamRef" type="xtce:NameReferenceType" use="required"/>
<attribute name="decodedStreamRef" type="xtce:NameReferenceType" use="required"/>
to
<attribute name="encodedStreamRef" type="xtce:NameReferenceWithPathType" use="required"/>
<attribute name="decodedStreamRef" type="xtce:NameReferenceWithPathType" use="required"/>
In the StreamRefType, change this line from:
<attribute name="streamRef" type="xtce:NameReferenceType" use="required">
to
<attribute name="streamRef" type="xtce:NameReferenceWithPathType" use="required">
In the ArrayDataTypeType, change this line from:
<attribute name="arrayTypeRef" type="xtce:NameReferenceType" use="required">
to
<attribute name="arrayTypeRef" type="xtce:NameReferenceWithPathType" use="required">
In the BaseDataType, change this line from:
<attribute name="baseType" type="xtce:NameReferenceType">
to
<attribute name="baseType" type="xtce:NameReferenceWithPathType">
In the ArgumentBaseDataType, change this line from:
<attribute name="baseType" type="xtce:NameReferenceType">
to
<attribute name="baseType" type="xtce:NameReferenceWithPathType">
In the ArgumentBaseTimeDataType, change this line from:
<attribute name="baseType" type="xtce:NameReferenceType">
to
<attribute name="baseType" type="xtce:NameReferenceWithPathType">
In the BaseTimeDataType, change this line from:
<attribute name="baseType" type="xtce:NameReferenceType">
to
<attribute name="baseType" type="xtce:NameReferenceWithPathType">
In the MemberType, change this line from:
<attribute name="typeRef" type="xtce:NameReferenceType" use="required"/>
to
<attribute name="typeRef" type="xtce:NameReferenceWithPathType" use="required"/>
In the ServiceRefType, change this line from:
<attribute name="serviceRef" type="xtce:NameReferenceType" use="required"/>
to
<attribute name="serviceRef" type="xtce:NameReferenceWithPathType" use="required"/>
At the conclusion of this, the "NameReferenceType" should no longer exist in the document.