XSLT Question
March 16, 2010 2:34 PM Subscribe
In XSLT, if I know that the entries in a certain field will always be of the form "ABC_1234blahblahblah", is there a way to get just "ABC_1234"? There will always be three letters, an underscore and four numerals, but the specific letters and numbers change from file to file, as does the length and content of the junk after the numbers. I don't actually know XSLT at all, I'm just trying to make a quick fix to some code written by someone else.
Best answer: If they've just got a simple [xsl:value-of select='field'/] you can change that to grab a substring out using e.g. [xsl:value-of select='substring(field,1,8)'/] to get the first 8 characters.
mefi ate my <!
posted by samj at 2:55 PM on March 16, 2010
mefi ate my <!
posted by samj at 2:55 PM on March 16, 2010
Best answer: Yeah, substring(). A simple tutorial.
posted by and hosted from Uranus at 2:59 PM on March 16, 2010
posted by and hosted from Uranus at 2:59 PM on March 16, 2010
Sounds like samj's got the answer. FYI, you can type angle brackets if you escape the characters (type "<" for "<" and ">" for ">"). Thus:
<xsl:value-of select='substring(field,1,8)' />
posted by The Winsome Parker Lewis at 3:00 PM on March 16, 2010
<xsl:value-of select='substring(field,1,8)' />
posted by The Winsome Parker Lewis at 3:00 PM on March 16, 2010
Response by poster: That's what I was looking for. Thanks!
posted by Awkward Philip at 3:00 PM on March 16, 2010
posted by Awkward Philip at 3:00 PM on March 16, 2010
This thread is closed to new comments.
posted by a snickering nuthatch at 2:48 PM on March 16, 2010