[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Approach for wrapping elements
7At 2003-01-07 13:24 -0600, you wrote:
I have a document that is of this form: An example is below. I've turned on indentation that you may wish to turn off. Note that I match those items that have immediate preceding sibling items and do nothing with them, because the first of all sets of adjacent sibling items handles all of the following adjacent ones. I hope this helps. .............. Ken T:\ftemp>type pratt.xml <?xml version="1.0" encoding="iso-8859-1"?> <test> <para>Paragraph text</para> <listitem>1st item</listitem> <listitem>2nd item</listitem> <listitem>3rd item</listitem> <para>More text</para> <para>Paragraph text</para> <listitem>1st item</listitem> <listitem>2nd item</listitem> <listitem>3rd item</listitem> <para>More text</para> <para>Paragraph text</para> <listitem>1st item</listitem> <listitem>2nd item</listitem> <listitem>3rd item</listitem> <para>More text</para> </test> T:\ftemp>type pratt.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="node()" name="copy-this"> <xsl:copy> <xsl:copy-of select="@*"/> <xsl:apply-templates/> </xsl:copy> </xsl:template> <xsl:template match="listitem[preceding-sibling::*[1][self::listitem]]"/> <xsl:template match="listitem"> <itemizedlist> <xsl:apply-templates mode="copy-adjacent" select="."/> </itemizedlist> </xsl:template> <xsl:template mode="copy-adjacent" match="listitem"> <xsl:call-template name="copy-this"/> <xsl:apply-templates select="following-sibling::*[1][self::listitem]" mode="copy-adjacent"/> </xsl:template> </xsl:stylesheet> T:\ftemp>saxon pratt.xml pratt.xsl <?xml version="1.0" encoding="utf-8"?> <test> <para>Paragraph text</para> <itemizedlist> <listitem>1st item</listitem> <listitem>2nd item</listitem> <listitem>3rd item</listitem> </itemizedlist> <para>More text</para> <para>Paragraph text</para> <itemizedlist> <listitem>1st item</listitem> <listitem>2nd item</listitem> <listitem>3rd item</listitem> </itemizedlist> <para>More text</para> <para>Paragraph text</para> <itemizedlist> <listitem>1st item</listitem> <listitem>2nd item</listitem> <listitem>3rd item</listitem> </itemizedlist> <para>More text</para> </test> 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) ISBN 0-13-065196-6 Definitive XSLT and XPath ISBN 0-13-140374-5 Definitive XSL-FO ISBN 1-894049-08-X Practical Transformation Using XSLT and XPath ISBN 1-894049-10-1 Practical Formatting Using XSL-FO 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
|