This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: Unwrapping trees
- From: Jeni Tennison <jeni at jenitennison dot com>
- To: Norman Walsh <ndw at nwalsh dot com>
- Cc: xsl-list at lists dot mulberrytech dot com
- Date: Thu, 13 Jun 2002 16:32:58 +0100
- Subject: Re: [xsl] Unwrapping trees
- Organization: Jeni Tennison Consulting Ltd
- References: <87ptyvrzvq.fsf@nwalsh.com>
- Reply-to: xsl-list at lists dot mulberrytech dot com
Hi Norm,
> Has anyone written the XSLT required to "unwrap" nested links?
I say "use SAX". This kind of transformation is really much better
suited to a event-driven paradigm than XSLT's declarative access.
If I had to use XSLT for some reason, then I'd do a two-step
transformation. First, create a flattened start/end structure,
something like:
<p>
text
<evt:start evt:name="a" href="1" />
text
<evt:end evt:name="a" />
<evt:start evt:name="span" />
<evt:start evt:name="a" href="2" />test<evt:end evt:name="a" />
text
<evt:end evt:name="span" />
<evt:start evt:name="a" href="1" />
text
<evt:end evt:name="a" />
text
</p>
Then use the usual methods to group that structure into the desired:
<p>
text
<a href="1">
text
</a>
<span>
<a href="2">test</a>
text
</span>
<a href="1">
text
</a>
</p>
I'm a bit confused, though, by the fact that the text 'text' within
the span element *isn't* within the second half of the wrapping a
element. I would have expected you to want:
<p>
text
<a href="1">
text
</a>
<span>
<a href="2">test</a>
</span>
<a href="1">
<span>
text
</span>
text
</a>
</p>
so before I start thinking about the actual XSLT, can you confirm that
the rule is that if an element within an a element contains another a
element, then that element is put at the same level as the containing
a element?
Cheers,
Jeni
---
Jeni Tennison
http://www.jenitennison.com/
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list