Skip to content

Commit

Permalink
feat: elements prefixed with 'selectBox' will add a label element wit…
Browse files Browse the repository at this point in the history
…h a comma-seperated list of element names which value is 'true'
  • Loading branch information
MLenterman committed Aug 26, 2024
1 parent d49d4f4 commit befbd65
Showing 1 changed file with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@
<xsl:apply-templates mode="injection-pass" />
</xsl:variable>
<!-- <xsl:copy-of select="$injectionPass" /> -->
<xsl:apply-templates select="$injectionPass/*" />
<xsl:variable name="renamePass">
<xsl:apply-templates mode="rename-pass" />
</xsl:variable>
<xsl:apply-templates select="$renamePass/*" />
</formdata>
</xsl:template>

Expand Down Expand Up @@ -44,7 +47,7 @@
</xsl:template>

<!-- Transform element names containing '-' to camelCase. -->
<xsl:template match="*[contains(name(), '-')]">
<xsl:template match="*[contains(name(), '-')]" mode="rename-pass">
<xsl:variable name="pascalCase" select="string-join(tokenize(name(current()), '-') ! (upper-case(substring(., 1, 1)) || substring(., 2)))" />

<xsl:element name="{lower-case(substring($pascalCase, 1, 1)) || substring($pascalCase, 2)}" namespace="{namespace-uri(current())}">
Expand All @@ -54,4 +57,14 @@
<xsl:apply-templates mode="#current" />
</xsl:element>
</xsl:template>

<!-- Add comma-seperated list of keys where the value is 'true' as sibling element suffixed with _label, for each element starting with 'selectBox' -->
<xsl:template match="*[starts-with(lower-case(name()), 'selectbox')]">
<xsl:element name="{name()}{'_label'}">
<xsl:value-of select="string-join(*[. = 'true']/name(), ',')" />
</xsl:element>
<xsl:element name="{name()}">
<xsl:apply-templates mode="#current" />
</xsl:element>
</xsl:template>
</xsl:stylesheet>

0 comments on commit befbd65

Please sign in to comment.