![]() |
![]() | ![]() | ![]() | Altova Mailing List Archives>Archive Index >comp.text.xml Archive Home >Recent entries >Thread Prev - Re: Flattening part of a structure [Thread Next] Re: Flattening part of a structureTo: NULL Date: 10/1/2007 10:50:00 AM
After playing around with this for a bit, I came up with this
stylesheet. There are probably improvements I could make to this, but
I'll be able to faff around with those on my own. Many thanks to
everyone who helped :-)
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:key name="unwrap"
match="para/node()[not(self::olist)]"
use=
"
concat
(
generate-id(..),'|',
generate-id(preceding-sibling::olist[1])
)
"/>
<xsl:key name="unwrap" match="para/olist"
use="concat(generate-id(..),'||')"/>
<xsl:output indent="yes"/>
<xsl:template match="para">
<p>
<xsl:apply-templates
select=
"@*|key('unwrap',concat(generate-id(),'|'))"/>
</p>
<xsl:for-each
select="key('unwrap',concat(generate-id(),'||'))">
<xsl:apply-templates select="."/>
<p>
<xsl:apply-templates
select=
"
../@*|
key
(
'unwrap',
concat(generate-id(..),'|',generate-id())
)
"/>
</p>
</xsl:for-each>
</xsl:template>
<xsl:template match="olist">
<ol><xsl:apply-templates /></ol>
</xsl:template>
<xsl:template match="li">
<li><xsl:apply-templates /></li>
</xsl:template>
<xsl:template match="document">
<doc><xsl:apply-templates/></doc>
</xsl:template>
</xsl:stylesheet>
| ![]() | ![]() | ![]() |
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | |||
|
