Comments on: XSL Break or Wrap String on Word Boundary http://blog.adamsbros.org/2009/11/22/xsl-break-string-on-word-boundary/ Sat, 14 Nov 2015 22:00:12 +0000 hourly 1 https://wordpress.org/?v=5.2.2 By: Trenton http://blog.adamsbros.org/2009/11/22/xsl-break-string-on-word-boundary/comment-page-1/#comment-1483 Thu, 06 Dec 2012 03:59:59 +0000 http://blog.adamsbros.org/?p=93#comment-1483 It’s been awhile since I used this. And you’re not a bother! 😀

1. I am not positive that the “new” is required. I thought it was at the time, but I could be wrong.
2. Yes, the first parameter is a way of telling the XSL processor to use the “lastIndexOf” on that string instance. So, I’m suspecting that the “new” was used to create the instance to be used. But again, not sure if it’s required, you could try it by just passing the raw XSL “substring” and see what happens.

Keep in mind that if you use XSL 2.0, there are a LOT of new features, and I’m betting you could do this easily, without a need to call a specific language, such as Java. Xalan doesn’t support 2.0, but saxon does. The coolest thing about XSL 2.0, is you can make native “functions” where you don’t have to apply a template, but it’s actually like any other XSL function call, such as “substring”. I could work up an example if I remember when I’m at work. I’ve done some XSL 2.0 stuff at work.

]]>
By: Eric http://blog.adamsbros.org/2009/11/22/xsl-break-string-on-word-boundary/comment-page-1/#comment-1482 Wed, 05 Dec 2012 18:00:44 +0000 http://blog.adamsbros.org/?p=93#comment-1482 I hate to be a bother about this, but I have a few more questions:
1. why is the String:new necessary prior to the call to lastIndexOf?
2. Isn’t lastIndexOf a method that operates on an instance of a string? It appears like it’s taking the string to search as the first parameter, andthe space (the search) as a second parameter. Can you explain why that works?

I’ve been working with Stylus Studio here and using External functions and have a similar requirement due to some overflow of text using Apache FOP. Stylus Studio runs your example perfectly IF I change the processor to XALAN-J rather than their built in. Otherwise, it can’t seem to find these functions, even though I would think they’d be “registered” by default.

The only change I had over your function was that there might not be a space in the input text, so it MUST wrap at 35 characters, regardless.

]]>
By: Trenton http://blog.adamsbros.org/2009/11/22/xsl-break-string-on-word-boundary/comment-page-1/#comment-1481 Wed, 05 Dec 2012 04:52:51 +0000 http://blog.adamsbros.org/?p=93#comment-1481 Sorry, that was a proprietary thing. I had copy/pasted an example from some real code, and massaged it.

]]>
By: Eric http://blog.adamsbros.org/2009/11/22/xsl-break-string-on-word-boundary/comment-page-1/#comment-1478 Wed, 05 Dec 2012 01:24:36 +0000 http://blog.adamsbros.org/?p=93#comment-1478 What is thAt XML-utilo.1.3-SNAPSHOT.jar? Is it used?

]]>