Subject: Re: [xsl] node traversal From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx> Date: Tue, 24 Feb 2004 11:12:18 -0500 |
I have a structure that _could_ be something like the following:
...
and I have to get to the following:
...
The idea is that any <p> elements remain unchanged, groups of sequential <inline> and text nodes are grouped together in a <p> element and any other elements, e.g. <table>, <math:math>, etc., are each wrapped with a <p> element.
T:\ftemp>type matthew.xsl <?xml version="1.0" encoding="iso-8859-1"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="stem"> <table-cell> <xsl:apply-templates mode="wrap"/> </table-cell> </xsl:template>
<xsl:template match="p" mode="wrap"><!--just pass p's through--> <p><xsl:apply-templates/></p> </xsl:template>
<xsl:template match="*|text()" mode="wrap"> <p><xsl:apply-templates select="."/></p> </xsl:template>
<!--ignore empty text nodes when wrapping--> <xsl:template match="text()[not(normalize-space())]" mode="wrap"/>
<xsl:template match="@*|node()"><!--identity for all other nodes--> <xsl:copy> <xsl:apply-templates select="@*|node()"/> </xsl:copy> </xsl:template> <!--this cleans up the output--> <xsl:template match="text()[not(normalize-space())]"/>
-- Public courses: Spring 2004 world tour of hands-on XSL instruction Each week: Monday-Wednesday: XSLT/XPath; Thursday-Friday: XSL-FO United States: Washington, DC March 15; San Francisco, CA March 22 Finland April 26; Hong Kong May 17; Germany May 24; London June 07 World-wide on-site corporate, government & user group XML training
G. Ken Holman mailto:gkholman@xxxxxxxxxxxxxxxxxxxx Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/ Box 266, Kars, Ontario CANADA K0A-2E0 +1(613)489-0999 (F:-0995) Male Breast Cancer Awareness http://www.CraneSoftwrights.com/s/bc
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] node traversal, David Carlisle | Thread | [xsl] Translating XSD into an XSLT,, Daniel Bryant |
Re: [xsl] node traversal, David Carlisle | Date | Re: Fw: [xsl] Using a parameter in , Ian Lang |
Month |