string - XSLT 1.0 extracting only the numeric numbers in block -



string - XSLT 1.0 extracting only the numeric numbers in block -

i'm new xslt 1.0. i'm stuck @ below after many seek using substring-before , substring-after.

my input string is txt=3000000-user united kingdom3000006-do not know user from3000004-user provide address

the output need below: <line>3000000</line> <line>3000004</line> <line>3000006</line>

the code used not able know auto loop through string next number

<line><xsl:value-of select="substring(normalize-space(translate(translate(substring-after(txt, '-'), $uppercase, $smallcase), $smallcase, ' ')), 0, 8)"/></line>

you need phone call recursive template here. assuming there @ to the lowest degree 1 hyphen between 2 numbers, try:

... <xsl:call-template name="tokenize"> <xsl:with-param name="text" select="normalize-space(translate(translate(txt, translate(txt, '-0123456789', ''), ''), '-', ' '))"/> </xsl:call-template> ... <xsl:template name="tokenize"> <xsl:param name="text"/> <xsl:param name="delimiter" select="' '"/> <xsl:choose> <xsl:when test="contains($text, $delimiter)"> <line> <xsl:value-of select="substring-before($text, $delimiter)"/> </line> <!-- recursive phone call --> <xsl:call-template name="tokenize"> <xsl:with-param name="text" select="substring-after($text, $delimiter)"/> </xsl:call-template> </xsl:when> <xsl:otherwise> <line> <xsl:value-of select="$text"/> </line> </xsl:otherwise> </xsl:choose> </xsl:template> edit:

alternatively, if each number 7 digits long followed hyphen and there no other hyphens in text, create bit simpler:

... <xsl:call-template name="tokenize"> <xsl:with-param name="text" select="txt"/> </xsl:call-template> ... <xsl:template name="tokenize"> <xsl:param name="text"/> <xsl:if test="contains($text, '-')"> <xsl:param name="token" select="substring-before($text, '-')"/> <line> <xsl:value-of select="substring($token, string-length($token) - 6)"/> </line> <!-- recursive phone call --> <xsl:call-template name="tokenize"> <xsl:with-param name="text" select="substring-after($text, '-')"/> </xsl:call-template> </xsl:if> </xsl:template>

string xslt-1.0 numeric

Comments

Popular posts from this blog

model view controller - MVC Rails Planning -

ruby on rails - Devise Logout Error in RoR -

html - Submenu setup with jquery and effect 'fold' -