[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
Kenny Akridge wrote:
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Re: [xsl] Pattern Matching a sting value
Subject: Re: [xsl] Pattern Matching a sting value From: scott gabelhart <swgabel@xxxxxxxxxxxx> Date: Fri, 06 Feb 2004 11:23:26 -0500 |
Kenny Akridge wrote:
Jim is right... you need to substring.You suggestion worked perfectly. Thank you Kenny!
This will work:
<?xml version="1.0"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="string"> <xsl:call-template name="extractor"> <xsl:with-param name="string" select="'font-family:'"/> </xsl:call-template> </xsl:template>
<xsl:template name="extractor"> <xsl:param name="string"/> <xsl:value-of select="substring-before(substring-after(., $string), ';')"/> </xsl:template>
</xsl:stylesheet>
-----Original Message----- From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of scott gabelhart Sent: Thursday, February 05, 2004 9:06 PM To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx Subject: Re: [xsl] Pattern Matching a sting value
Jim Fuller wrote:
Jim,[mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of scott gabelhart
Sent: 06 February 2004 01:14
To: XSL-List@xxxxxxxxxxxxxxxxxxxxxx
Subject: [xsl] Pattern Matching a sting value
How in XSLT 1.0 do you interogate a specific portion of a string?
$stg = "font:...;font-family:Arial;color:#FFFFF;...."
I am only interested in the portion of this string that contains Arial.
Not sure what interested means, if you want to test for the existance use the boolean contains() function;
contains($stg,'Arial') would return true
Otherwise use the following string based functions
string substring-before(string, string) string substring-after(string, string) string substring(string, number, number?) string concat(string, string, string*) number string-length(string?)
You might need these as well;
string normalize-space(string?) string translate(string, string, string)
Check out here for specific techniques;
http://www.dpawson.co.uk/xsl/sect2/N7240.html
Otherwise if you want something with regular expressions or more advanced string handling like replacing text check out www.exslt.org.
Gl, Jim Fuller
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
specifically I have a attribute that contains many values that I have to
break apart and set to individual attribute values so
a string that contains "color:#FFFFF;font-family:Arial;font-weight:bold;" I would need to select only the value begining after the : in font-family and ending with;before font-weight.
Do any of the string function above support the functionality I am looking for? Thanks for the tip on the contains function. Already using that function to determine if a attribute string value contains font-family in the first place.
- Scott
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] Pattern Matching a sting , Kenny Akridge | Thread | RE: [xsl] Pattern Matching a sting , Michael Kay |
Re: [xsl] text() word lists, David Carlisle | Date | Re: [xsl] Pattern Matching a sting , scott gabelhart |
Month |
Keywords