[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: processing text nodes one character at a time
On 9/26/06, Dimitre Novatchev <dnovatchev@xxxxxxxxx> wrote:
On 9/26/06, Dimitre Novatchev <dnovatchev@xxxxxxxxx> wrote: > The original poster asked: > > How to output a specific character in front of every character in a > given string? > > Part I: > ==== > This is a problem that is easily solved with FXSL. the solution is > this one-liner: > > > f:str-map(f:flip(f:concat2(), '|'), string(/*))
and this woud be the place to put the </xsl:stylesheeet> end-tag when the definition of the various f:concat2() functions were part of FXSL (I'll be uploading them shortly). Right at this moment we cannot import them but they are inline: <xsl:function name="f:concat2" as="xs:string"> <xsl:param name="pStr1" as="xs:string"/> <xsl:param name="pStr2" as="xs:string"/> <xsl:sequence select="concat($pStr1, $pStr2)"/> </xsl:function> <xsl:function name="f:concat2" as="element()"> <xsl:param name="pStr1" as="xs:string"/> <xsl:sequence select="f:curry(f:concat2(),2,$pStr1)"/> </xsl:function> <xsl:function name="f:concat2" as="element()"> <f:concat2/> </xsl:function> <xsl:template match="f:concat2" mode="f:FXSL"> <xsl:param name="arg1" as="xs:string"/> <xsl:param name="arg2" as="xs:string"/> <xsl:sequence select="f:concat2($arg1, $arg2)"/> </xsl:template> </xsl:stylesheet> The sample input on which this stylesheet was applied can be found at: http://sourceware.org/ml/xsl-list/2001-12/msg00651.html The result is the same text, but in which every character is preceded by the "|" character. The benefit of using the function f:str-map() is more obvious, when the single characters of the string have to be transformed in a more complex way, which excludes other straightforward solutions -- for example there were examples in the past (with f:str-zipWith()) of implementing bitwise operations -- Cheers, Dimitre Novatchev --------------------------------------- Truly great madness cannot be achieved without significant intelligence. --------------------------------------- To invent, you need a good imagination and a pile of junk ------------------------------------- You've achieved success in your field when you don't know whether what you're doing is work or play
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|