
George, I greatly appreciate your help in this. Im a C++ programmer, and it seems XML doesnt use the same logic at certain instances. I just have 2 more problems: FIRST: In this problem, I just need the last four digits of the ISBN. But the catch is that the ISBN length is not constant, but is always greater than 4. XML FILE <ISBN>23fds783222s</ISBN> <ISBN>f2h123as</ISBN> <ISBN>2hgfhhgf3432h123asssz</ISBN> XSL FILE: <?xml version="1.0" encoding="UTF-8" ?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:output encoding="UTF-16" method="xml" indent="yes"/> <xsl:template match="/"> <xsl:for-each select="ISBN"/> <xsl:value-of select="substring-after(select="string-length()", 4)"/> </xsl:template> </xsl:stylesheet> SECOND: I have no idea how to go about this one. I just have to select the text before the number. Do you have any idea? XML FILE <INFO>hotmail 1990</INFO> <INFO>some text here 2000</INFO> <INFO>some more text gere 9092</INFO> I greatly appreciate your help George. Thanks a MILLION Aga Shirazi

FIRST: In this problem, I just need the last four digits of the ISBN. But the catch is that the ISBN length is not constant, but is always greater than
Hi Aga, 4.
XML FILE <ISBN>23fds783222s</ISBN> <ISBN>f2h123as</ISBN> <ISBN>2hgfhhgf3432h123asssz</ISBN>
If you want the last for characters from a string you can use something like: <xsl:variable name="value" select="."/> <xsl:value-of select="substring($value, string-length($value)-3)"/> If you want to remove eventual characters before getting the last 4 characters you can select the value as below: <xsl:variable name="value" select="translate(., 'abcde....', '')"/>
SECOND: I have no idea how to go about this one. I just have to select the text before the number. Do you have any idea?
XML FILE <INFO>hotmail 1990</INFO> <INFO>some text here 2000</INFO> <INFO>some more text gere 9092</INFO>
If you know you have a 4 digit number then you can use substring to get it: <xsl:value-of select="substring($value, 1, string-length($value)-4)"/> If you know that the text does not contain numbers you can use translate to remove the digits: <xsl:value-of select="translate($value, '0123456789', '')"/> otherwise you can use a template to remove digits from the end: <xsl:template name="selectBeforeNumber"> <xsl:param name="value" select="''"/> <xsl:variable name="c" select="substring($value, string-length($value))"/> <xsl:choose> <xsl:when test="$c='0' or $c='1' or $c='2' or $c='3' or $c='4' or $c='5' or $c='6' or $c='7' or $c='8' or $c='9'"> <xsl:call-template name="selectBeforeNumber"> <xsl:with-param name="value" select="substring($value, 1, string-length($value)-1)"/> </xsl:call-template> </xsl:when> <xsl:otherwise> <xsl:value-of select="$value"/> </xsl:otherwise> </xsl:choose> </xsl:template> and call it like below if the current selection is an INFO node: <xsl:call-template name="selectBeforeNumber"> <xsl:with-param name="value" select="."/> </xsl:call-template> Regards, George
participants (2)
-
Aga Shirazi
-
George Cristian Bina