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

RE: Generic stylesheet to flatten XML hierarchy

Subject: RE: Generic stylesheet to flatten XML hierarchy
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Sat, 5 Dec 2009 10:26:42 -0000
RE:  Generic stylesheet to flatten XML hierarchy
> But probably you know exactly what you're doing, there is a perfectly
> reasonable algorithm for what you want, and I just haven't
> understood.
> 

I did once write a fairly generic stylesheet for a client that was inspired
by the behaviour of the IDEs that show an XML document in "grid" layout. It
ended up being an interesting set of heuristics that worked quite well for a
reasonable range of input documents (and didn't fail on others). It's best
seen as producing nested tables representing successive levels of hierarchy,
with each table being formatted in one of a number of different styles based
on pattern matching: a "named colummns" style where a sequence of elements
each has N children with different names, a "list" style where elements have
N children with the same name, a "mixed content" style where elements are
displayed as text, and so on. The patterns have to be applied consistently
across the whole document, so for example every order-item element is
displayed in the same way regardless of its own individual structure. 

I can't remember why we decided to drive it from the actual data in instance
documents rather than from the schema, but there was a good reason at the
time.

It was actually a meta-stylesheet, if I remember right: rather than doing
the transformation, it generated the stylesheet to do the transformation.
The idea of that was that once you had the logic to display one purchase
order (say), you would use the same logic to display other purchase orders,
so you got a consistent rendition for all of them; it also allowed
hand-tweaking of the rules.

Regards,

Michael Kay
http://www.saxonica.com/
http://twitter.com/michaelhkay 

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.