[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: Using XSLT to add markup to a document
Jim,
Charles is correct (this is an example of "up-translation"), *but*.... This problem has been solved with recursive string-crunching techniques. I don't have time to do the exposition now, but I think there may be something in EXSLT that does this. It's not pretty, or efficient, but it works. (I did this way back when cutting my teeth on the language, making a concordancer out of XSLT.) Generally the approach is with a template taking a string as a parameter; test the string with the contains() function; if it doesn't pass copy it to output. If it does, use string-before and copy the front part to output, then make your node, then pass the remainder as a parameter back to the template recursively. Charles is also correct to observe Dimitre has a sophisticated way to do this, optimized for efficiency -- so be sure to check out FXSL as well. I also agree that there are other tools that may be far better at this, especially if you have large documents and this is the only change to make. Cheers, Wendell At 04:52 PM 7/3/2003, Charles wrote: As Ed used to say to Johnny, "You are correct, sir!". XSLT 1.0 is good at working with elements and attributes and so forth. What you want to do is create an element where none existed before and there are no XML semantic cues to identify them. You have two choices, upgrade to the latest Saxon version which supports XSLT 2.0 features like regular expression matching, or go the non-XSL route and pre-process your XML document with Perl (or another language that supports regular expression matching) and add the new markup before you run your XSLT transform. Having said that, I expect that Dimitre Novachev will now tell you that he has just the thing you need in his FXSL bag o' tricks. ====================================================================== Wendell Piez mailto:wapiez@xxxxxxxxxxxxxxxx Mulberry Technologies, Inc. http://www.mulberrytech.com 17 West Jefferson Street Direct Phone: 301/315-9635 Suite 207 Phone: 301/315-9631 Rockville, MD 20850 Fax: 301/315-8285 ---------------------------------------------------------------------- Mulberry Technologies: A Consultancy Specializing in SGML and XML ====================================================================== XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
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
|