Subject: Re: [xsl] Adding hierarchy From: Mukul Gandhi <mukulgw3@xxxxxxxxx> Date: Sun, 12 Oct 2003 21:23:53 -0700 (PDT) |
Hi Jim, Please try the following XSL -- <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/> <xsl:template match="/root"> <root> <xsl:for-each select="*"> <xsl:if test="name(following-sibling::*[1]) = 'blankLIne' "> <xsl:copy-of select="preceding-sibling::*" /> <xsl:copy-of select="." /> </xsl:if> </xsl:for-each> <xsl:for-each select="lineGroup"> <xsl:if test="name(preceding-sibling::*[1]) = 'blankLIne' "> <lineGroup type="stanza"> <xsl:copy-of select="."/> <xsl:copy-of select="following-sibling::lineGroup" /> </lineGroup> </xsl:if> </xsl:for-each> <xsl:for-each select="lineGroup"> <xsl:if test="not(name(following-sibling::*[1]) = 'lineGroup') "> <xsl:copy-of select="following-sibling::*" /> </xsl:if> </xsl:for-each> </root> </xsl:template> </xsl:stylesheet> When the above XSL is applied to the XML -- <?xml version="1.0" encoding="UTF-8"?> <root> <A> <x>123</x> </A> <blankLIne /> <lineGroup> <line></line> <line></line> </lineGroup> <lineGroup> <line></line> <line></line> <lineGroup> <line></line> <line></line> </lineGroup> <line></line> </lineGroup> <B> <y>abc</y> </B> </root> it produces output -- <?xml version="1.0" encoding="UTF-8"?> <root> <A> <x>123</x> </A> <lineGroup type="stanza"> <lineGroup> <line/> <line/> </lineGroup> <lineGroup> <line/> <line/> <lineGroup> <line/> <line/> </lineGroup> <line/> </lineGroup> </lineGroup> <B> <y>abc</y> </B> </root> I have added structures <root>, <A> and <B> to illustrate concept.. I hope such a XSL was required .. Regards, Mukul --- Jim_Albright@xxxxxxxxxxxx wrote: > Thank you for help in the past. Next question. > > Starting with this piece, I want to add a wrapper > around a whole set of > lineGroup elements > > <blankLIne> > <lineGroup> > <line></line> > <line></line> > </lineGroup> > <lineGroup> > <line></line> > <line></line> > <lineGroup> > <line></line> > <line></line> > </lineGroup> > <line></line> > </lineGroup> > <p>.......or any non lineGroup element ..... > > should change to > <lineGroup type="stanza"> > <lineGroup> > <line></line> > <line></line> > </lineGroup> > <lineGroup> > <line></line> > <line></line> > <lineGroup> > <line></line> > <line></line> > </lineGroup> > <line></line> > </lineGroup> > </lineGroup> > <p>.......or any non lineGroup element ..... > So a blankLine as preceding-sibling to lineGroup is > the trigger to then > process all following-sibling lineGroups. > > A 2.0 solution is welcome if needed. > > > Jim Albright > 704 843-0582 > Wycliffe Bible Translators > > > > XSL-List info and archive: > http://www.mulberrytech.com/xsl/xsl-list > __________________________________ Do you Yahoo!? The New Yahoo! Shopping - with improved product search http://shopping.yahoo.com XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Adding hierarchy, Jim_Albright | Thread | [xsl] Re: Adding hierarchy, Dimitre Novatchev |
[xsl] RE:adding hierarchy, Jim_Albright | Date | [xsl] Re: Adding hierarchy, Dimitre Novatchev |
Month |