I have this working pretty well, but was wondering if there is a better way
to do this?
In both cases <sectionNumber> and <tagName>, I am testing the 1st 4
characters for some value (GC1_, GC2_, GC3_ etc) and am changing the value
based on this.
In <SectionNumber> it is going to be either a 0,1,2 or 3. In TagName, I
am
changing the 1st 4 characters to either GS_ or GR_. I just doing a bunch of
"when" statements and was wondering if there is a better way to do
it.
Also, another possibility was to test the 1st 2 characters as well as the
4th character for an "_". Would I do it like:
<xsl:when test="substring(name(),1,2) = 'GC' & substring(name(),4,1)
=
'_'"/>
Here is the current code.
<xsl:template match="FIELDS/*">
<form>
<sectionNumber>
<xsl:choose>
<xsl:when test="substring(name(),1,4) = 'GC1_'">
<xsl:text>1</xsl:text>
</xsl:when>
<xsl:when test="substring(name(),1,4) = 'GC2_'">
<xsl:text>2</xsl:text>
</xsl:when>
<xsl:when test="substring(name(),1,4) = 'GC3_'">
<xsl:text>3</xsl:text>
</xsl:when>
<xsl:when test="substring(name(),1,4) = 'RC1_'">
<xsl:text>1</xsl:text>
</xsl:when>
<xsl:when test="substring(name(),1,4) = 'RC2_'">
<xsl:text>2</xsl:text>
</xsl:when>
<xsl:when test="substring(name(),1,4) = 'RC3_'">
<xsl:text>3</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>0</xsl:text>
</xsl:otherwise>
</xsl:choose>
</sectionNumber>
<primary>True</primary>
<formName>
<xsl:value-of select="../../@FORMCODE"/>
</formName>
<tagName>
<xsl:choose>
<xsl:when test="substring(name(),1,4) = 'GSU_'">
<xsl:text>GS</xsl:text>
<xsl:value-of select="substring(name(),4)"/>
</xsl:when>
<xsl:when test="substring(name(),1,4) = 'GC1_'">
<xsl:text>GS</xsl:text>
<xsl:value-of select="substring(name(),4)"/>
</xsl:when>
<xsl:when test="substring(name(),1,4) = 'GC2_'">
<xsl:text>GS</xsl:text>
<xsl:value-of select="substring(name(),4)"/>
</xsl:when>
<xsl:when test="substring(name(),1,4) = 'GC3_'">
<xsl:text>GS</xsl:text>
<xsl:value-of select="substring(name(),4)"/>
</xsl:when>
<xsl:when test="substring(name(),1,4) = 'RC1_'">
<xsl:text>GR</xsl:text>
<xsl:value-of select="substring(name(),4)"/>
</xsl:when>
<xsl:when test="substring(name(),1,4) = 'RC2_'">
<xsl:text>GR</xsl:text>
<xsl:value-of select="substring(name(),4)"/>
</xsl:when>
<xsl:when test="substring(name(),1,4) = 'RC3_'">
<xsl:text>GR</xsl:text>
<xsl:value-of select="substring(name(),4)"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="name()"/>
</xsl:otherwise>
</xsl:choose>
</tagName>
<flags>0</flags>
<format>0</format>
<value>
<xsl:value-of select="."/>
</value>
</form>
Thanks,
Tom
|