Skip to content

Commit

Permalink
add some more error checking to the xslt implementation of df-other-v…
Browse files Browse the repository at this point in the history
…ectors-type
  • Loading branch information
BenLubar committed Apr 30, 2020
1 parent 944b7f5 commit a2e3a62
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions lower-1.xslt
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,30 @@
<xsl:variable name='enum-name' select='@index-enum'/>
<xsl:variable name='item-type' select='@item-type'/>

<xsl:for-each select="*[not(name()='stl-vector' or name()='comment' or name()='code-helper')]">
<xsl:message terminate="yes">
Error: df-other-vectors-type may only contain stl-vector fields. (<xsl:value-of select='name(.)'/>)
</xsl:message>
</xsl:for-each>

<xsl:for-each select="$vectors">
<xsl:variable name='enum-key' select='@name'/>
<xsl:variable name='enum-item' select='/data-definition/enum-type[@type-name=($enum-name)]/enum-item[@name=($enum-key)]'/>

<xsl:choose>
<xsl:when test='count($enum-item) = 0'>
<xsl:message terminate="yes">
Error: field <xsl:value-of select='$enum-key'/> is not a member of enum <xsl:value-of select='$enum-name'/>
</xsl:message>
</xsl:when>
<xsl:when test="starts-with(($enum-item/@value), '-')">
<xsl:message terminate="yes">
Error: field <xsl:value-of select='$enum-key'/> corresponds to an enum value of <xsl:value-of select='$enum-item/@value'/>
</xsl:message>
</xsl:when>
</xsl:choose>
</xsl:for-each>

<ld:global-type ld:meta='struct-type' ld:subtype='df-other-vectors-type' ld:level='0' type-name='{@type-name}' index-enum='{$enum-name}' item-type='{$item-type}'>
<xsl:apply-templates select="@comment|@since"/>
<xsl:apply-templates select="comment|code-helper">
Expand Down

0 comments on commit a2e3a62

Please sign in to comment.