|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: XSL pattern needed for begin/end elements
Hi Tracy,
This is a hard problem, and one for which XSLT was not designed. Nonetheless, there is enough experience around that some guidance is possible. At 12:14 PM 7/7/2004, you wrote: I'm looking for an XSL pattern to solve the problem of going from XML that has separate begin and end elements to one that does not. In other words, the "separate begin and end elements" are merely markers for something not-yet-an-element (actually a sequence of nodes), which you want to turn into an element. In other words, this is an up-conversion whereby you want to "wrap" a set of nodes in another (new) node, depending on their relations to other nodes (their "markers"). Please, please note that I do not control either the source or target XML formats. If I did, this would be much easier. Or not -- the problem they're trying to solve arguably is not well handled by XML. Caveat: depending on how the problem is being scoped. It could be, as you imply, that a much simpler solution is possible, if the problem is scoped more narrowly. Scoped broadly, this is the problem of "multiple concurrent hierarchies" (short syntax: "overlap"), which is a fairly hot research area: see the preliminary program for the Extreme conference in Montreal, at http://www.mulberrytech.com/Extreme/Program.html -- especially Wednesday, "Overlap Day". Source XML snip: If you can bank on this assumption, it makes it possible to address this using "positional grouping". There are two main approaches to this in XSLT 1.0 (covered in the FAQ); but neither are as clean and simple as an XSLT 2.0 group-by construct, which you have available in Saxon 8. (If Jeni isn't busy with mini-Jeni at the moment, maybe she'll offer this one, or Mike or someone else will. Having only poked at it, I can say only that it's somewhat trickier than the general case: you can't use the "group-starting-with" grouping criterion because your end-markers are a different element type. ;-) If you can't assume these are siblings, then you're in uncharted territory ("Here be Dragons"). You could pull XSLT into service as a tag-writing application (requires that you invoke a serializer to implement the conversion, and use the dreaded "disable-output-escaping" feature to write tags) -- but this can't guarantee well-formed output. In fact, if you have to do this (if you can't use a grouping technique) you can more or less assume your output will be XML only by accident. Cheers, Wendell
|
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
|

Cart








