Re: [xsl] Unwrapping trees

Subject: Re: [xsl] Unwrapping trees
From: David Carlisle <davidc@xxxxxxxxx>
Date: Fri, 14 Jun 2002 12:31:37 +0100
Norm

> I can't quite parse that at 7am. Uhm, but the rule is "pull the nested anchors"
> to the top so they aren't nested anymore without otherwise changing the markup
> to the greatest extent possible.

I've tried this before (with presumably the same intent as you, to
ensure that the html output of a stylesheet is well formed)  but you
need to "close all open elements on the stack" which isn't so easy in
xslt at the best of times, even with your simple one level <span> but it
gets harder to decide what it means to flatten out a table like 
<a href="jhgf">
<table>
...

when you find that half the entries contain <a elements.

I ended up implementing a simpler rule to ensure valid output.

Don't generate a in the result if you've already inside an a.

Or to phrase it as a second-pass cleanup as in your original request.

Do an identity transform but replace any nested a elements by their
contents. This is much simpler to achieve and I'm not sure that the end
result is less usable in many cases.


.. of course in XPath2/Xquery you'd just specify you want the output to
typecheck against the xhtml schema and the static analysis of the query
will ensure that the result is always valid. that is the point of adding
all this schema type checking in XPath2/Xquery we're told aren't we?


David

_____________________________________________________________________
This message has been checked for all known viruses by Star Internet
delivered through the MessageLabs Virus Scanning Service. For further
information visit http://www.star.net.uk/stats.asp or alternatively call
Star Internet for details on the Virus Scanning Service.

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread