[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: "group-starting-with" and "analyze-string" altern

Subject: Re: "group-starting-with" and "analyze-string" alternative for XSLT 1.0?
From: Abel Braaksma <abel.online@xxxxxxxxx>
Date: Tue, 28 Aug 2007 00:04:21 +0200
Re:  "group-starting-with" and "analyze-string"  altern
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 MSXMLtherefore, it doesnt support 2.0. Ive 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. Im using for-each-group with group-starting-with
Ive read up on Muenchian grouping, but havent been able to figure out a good work-around. I havent 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. Im 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

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.