|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: node traversal
At 2004-02-24 10:06 -0500, Matthew L. Avizinis wrote:
I have a structure that _could_ be something like the following: This can be done in part with modes ... and I've given a start below but I've been called away to a meeting and I cannot finish ... the only requirement I haven't met yet is the grouping of inlines and sibling text nodes into a single <p> node ... that's heavy lifting and I've run out of volunteer list time for today and signing off the lists for the rest of the day. I hope the example below gets you started ... sorry I can't finish it today. .................. Ken T:\ftemp>type matthew.xml <stem xmlns:math="math"> <table font-size="7"> .....more tags..... </table> <inline font-weight="bold" font-style="italic">Managerial accounting</inline> differs from financial accounting in that financial accounting is <p indent="15" left-indent="8">This is a test. This is a test of the emergency everything system.</p> <p indent="10" left-indent="5">This is a second test. This is a test of the emergency everything system.</p> <math:math width="100" height="18" id="test01"> ......more tags...... </math:math> there could be another text node here, for example <math:math width="50" height="15" id="test02"> .......more tags..... </math:math> </stem> 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:output indent="yes"/> <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())]"/></xsl:stylesheet> T:\ftemp>saxon matthew.xml matthew.xsl <?xml version="1.0" encoding="utf-8"?> <table-cell> <p> <table xmlns:math="math" font-size="7"> .....more tags..... </table> </p> <p> <inline xmlns:math="math" font-weight="bold" font-style="italic">Managerial accounting</inline> </p> <p> differs from financial accounting in that financial accounting is </p> <p>This is a test. This is a test of the emergency everything system.</p> <p>This is a second test. This is a test of the emergency everything system.</p> <p> <math:math xmlns:math="math" width="100" height="18" id="test01"> ......more tags...... </math:math> </p> <p> there could be another text node here, for example </p> <p> <math:math xmlns:math="math" width="50" height="15" id="test02"> .......more tags..... </math:math> </p> </table-cell> T:\ftemp>rem Done
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 XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








