xsl-list
[Top] [All Lists]

Re: [xsl] "group-starting-with" and "analyze-string" alternative for XSLT 1.0?

2007-08-27 15:06:17
Steven Kaminski wrote:

I have written an XSLT for the source below that works well in XSLT 2.0. However, the application with which I need to use it (MindJet MindManager 7) only supports MSXML—therefore, it doesn’t support 2.0. I’ve tried it. No go.

There are only three XSLT 2.0 processors around. You can try Saxon 8.9, Gestalt or Altova's xslt parser. If you cannot make Mindjet use another processor, you can use msxml:script to include javascript (or jscript, no need to care about ms extensions, any msxml:script is un-portable anyway) that does the tricks you want: regular expressions.

So how can I do this in XSLT 1.0? Specifically:
1. I’m using for-each-group with group-starting-with
I’ve read up on Muenchian grouping, but haven’t been able to figure out a good 
work-around. I haven’t found a 1.0 grouping discussion that addresses this kind of grouping.

group-starting-with is, imo, better addressed with a tree-walking algorithm, not Muenchian grouping, even though you can use either. Tree walking is quite easy to implement and there are many sources in both the faq, the internet, and some books (I believe it is discussed in the XSLT Cookbook).

2. I’m using the analyze-string and regex to reformat the HTML in the CDATA sections to correctly insert double-quotes and a few other things. There must be a work-around for XSLT 1.0, but thinking about it makes my brain hurt.

It sounds to me that you are doing something you shouldn't be doing at all: having HTML as text (in your cdata sections of your source). If you can make the source change to serve you xml/html blocks instead it will be much easier.

Alternatively, if you need to parse it and it is correct XHTML (the parts in your cdata sections clearly are not XHTML), and you can use saxon, you can use saxon:parse($input) to parse it as XML and apply it (but your original inquiry was you couldn't use xslt 2.0...)

Yes, it would make my brain hurt too. But it can be done. It will take a couple of weeks, or more, depending on your demands (your regexes are rather simple, so it shouldn't be too hard though). Spend these weeks persuading the one that gave you this crooked source to make it proper and easier parsable.

I see that you put the CDATA sections as string in an attribute? Why do you make it so hard, do you really need that? The same solution surely must be possible in a much easier way?


Sample Source File:

that was altogether about 20k of non-indented source+xslt+output. I'm afraid that there aren't many hobbyists around here that will voluntarily delve into a bunch of unknown code. It is usually far better to show a cut-down example of what you need, nicely formatted, so that we can quickly grasp what your problem is.


Cheers,
-- Abel Braaksma

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>