Subject: RE: [xsl] substrings with entities or not. From: Adam Van Den Hoven <Adam.Hoven@xxxxxxxxxxxx> Date: Mon, 5 Mar 2001 10:39:16 -0800 |
To elaborate on my previous question, what I'm trying to do is find all the quotation marks and wrap them in <q> tags. As a result, I've come up with the following template. I think this should work but I'm not 100% certain. <xsl:template name="SplitText"> <xsl:param name="content" /> <xsl:variable name="before" select="substring-before($content, '"')" /> <xsl:variable name="quote" select="substring-before(substring-after($content, '"'), '"')" /> <xsl:variable name="after" select="substring-after(substring-after($content, '"'), '"')" /> <xsl:choose> <xsl:when test="0 < string-length($before)" > <xsl:value-of select="$before" /> <q> <xsl:value-of select="$quote" /> </q> <xsl:call-template name="SplitText"> <xsl:with-param name="content" select="$after" /> </xsl:call-template> </xsl:when> <xsl:otherwise> <xsl:value-of select="$content" /> </xsl:otherwise> </xsl:choose> </xsl:template> Does anyone see any problem with this? or am I going to have to do some funky conditional testing. > So given the following XML > <someXML> > <something>Adam said, "This is a lot of work!"</something> > <something>Adam also said, "This is a lot of > work!"</something> > </someXML> > > I want to get the strings <<Adam said, >> and <<Adam also said, >> > > can I use > > <xsl:value-of select="substring-before(something, '"')" /> > > and exect everything to work out OK? My problem is that I can't really > guarantee that I'm going to have either the character or the > entity in my > source. > > > > Adam van den Hoven > > Internet Application Developer > > Blue Zone > > tel. 604.685.4310 > > fax. 604.685.4391 > > Blue Zone makes you interactive.(tm) http://www.bluezone.net/ > > > > 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] substrings with entities , Raj Avula | Thread | [xsl] multilingual web site, skhurshid |
Re: [xsl] [exsl] EXSLT 1.0 - Common, David Carlisle | Date | Re: [xsl] substrings with entities , David Carlisle |
Month |