 |
 |
 |
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
|
 | 



|  |
These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.
|  |
| |
 |
 |
 |