This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: how to merge tags/nodes via transform?


Another solution...still not too efficient or "wise" =)


<xsl:stylesheet xmlns:xsl = "http://www.w3.org/1999/XSL/Transform";

version = "1.0" >

    <xsl:output method = "xml" indent = "yes" />
	
      <xsl:template match = "root" >
	<root>
	<b>
	<xsl:for-each select="b">
	<xsl:if test="position()&lt;=3">
	 <xsl:value-of select="." />
	 </xsl:if>
	 </xsl:for-each>
	</b>
	<xsl:text> and </xsl:text>

	<b>
	<xsl:for-each select="b">
	<xsl:if test="position()&gt;3">
	 <xsl:value-of select="." />
	 </xsl:if>
	 </xsl:for-each>
	</b>
	</root>
		
	</xsl:template>
</xsl:stylesheet>



Lainaus Jarkko.Moilanen@uta.fi:

> Lainaus rbondi@ergito.com:
> 
> > Could someone please suggest a template to convert e.g.:
> 
> Dummy solution:
> 
> <xsl:stylesheet xmlns:xsl = "http://www.w3.org/1999/XSL/Transform";
> version = "1.0" >
> 
>     <xsl:output method = "xml" indent = "yes" />
> 	
>       <xsl:template match = "root" >
> 	<root>
> 	<b>
>         <//select 1 to 3 <b> - elements
>         <xsl:value-of select="b[1]" />
> 	<xsl:value-of select="b[2]" />
> 	<xsl:value-of select="b[3]" />
> 	</b>
> 	<xsl:text>and</xsl:text>
> 	
> 	<b>
> 	 <xsl:value-of select="b[4]" />
> 	 <xsl:value-of select="b[5]" />
> 	<xsl:value-of select="b[6]" />
> 	<xsl:value-of select="b[7]" />
> 	</b>
> 	</root>
> 	
> 		
> 	</xsl:template>
> </xsl:stylesheet>
> 
> 
> 
> 
> > 
> > <root>
> >  <b>d</b>
> >  <b>o</b>
> >  <b>g</b>
> > and
> >  <b>c</b>
> >  <b>a</b>
> >  <b>t</b>
> >  <b>s</b>
> > </root>
> > 
> > into
> > 
> > <root>
> >  <b>dog</b>
> >  and
> >  <b>cats</b>
> > </root>
> > 
> > Many thanks in advance,
> > Richard Bondi
> > 
> > 
> > 
> > 
> > 
> >  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
> > 
> > 
> 
> 
> 
> ****************************************************************
> Jarkko Moilanen          "Erehtyminen on inhimillista, 
> Researcher/ ITCM         mutta todella suuret mokat 
> jm60697@uta.fi           vaativat tietokoneen käyttöä."         
> www.uta.fi/~jm60697                                           
> GSM: +358 50 3766 927                                         
> ****************************************************************
> * ITCM | Information Technology and Crisis Management            
> * http://www.itcm.org                                            
> ****************************************************************
> 
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
> 
> 



****************************************************************
Jarkko Moilanen          "Erehtyminen on inhimillista, 
Researcher/ ITCM         mutta todella suuret mokat 
jm60697@uta.fi           vaativat tietokoneen käyttöä."         
www.uta.fi/~jm60697                                           
GSM: +358 50 3766 927                                         
****************************************************************
* ITCM | Information Technology and Crisis Management            
* http://www.itcm.org                                            
****************************************************************

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]