[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Move leading/trailing spaces outside (XSLT 2.0)
Michael Kay wrote:
<xsl:template match="e">I think that needs to be Yves, Please note the subtle differences between the above mentioned solution and the one I proposed. Both have their pros and cons. Depending on your final needs, one or the other may suit you best. Using <xsl:analyze-string select="." regex="^(\s*)(.+?)(\s*)$"> will match the total string, so no need for using non-matching-substring. This has the advantage that you can do string-manipulation on the whole match at once, using regex-group(1), (2) and (3). If you only do string-replacement, your can optimize this with the replace() function. Doing <xsl:analyze-string select="." regex="^\s+|\s+$"> is quicker, has the advantage of separating logic, but has the disadvantage that you cannot intermix the matching and non-matching strings (meaning, when you are in non-matching-substring, it contains the non-space content of your match, and you cannot get the matching-substring from that instruction and vice versa). If you need to create a node where the match is part of a childnode of the non-match, of vv, use the first solution with regex-group, if the nodes are siblings, you can use either (whichever you find clearest), if the nodes are only text-nodes, you can use replace() instead, depending a bit on the complexity of the match. If you mix text with nodes (mixed content), it depends a bit (but you cannot use replace()). -- Abel
|
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
|