Altova Mailing List Archives>Archive Index >comp.text.xml Archive Home >Recent entries >Thread Prev - Re: Options for looping through children with different element names [Thread Next] Re: Options for looping through children with different element namesTo: NULL Date: 4/2/2009 4:07:00 AM On Apr 2, 5:56=A0am, Martin Honnen <mahotr...@yahoo.de> wrote: > johkar wrote: > > Assume XML parent element has lots of children that are all unique > > element names. =A0Is the only way to loop through them to use a wildcar= d > > (*) for the element name in the for-each or apply-templates call? =A0I > > am looking for efficiency because I am going to have to do this many > > times in the XSLT and there could be hundreds of child element names > > for any given parent element. =A0Note, I don't have control over the XM= L > > tree structure. > > > Xpath: =A0 /category/businesstype/* > > > <category> > > =A0 =A0 =A0 <businesstype> > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 <specialty>Some text</specialty> > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 <bigbox>Some text></bigbox> > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 <internetonly>Some text</internetonly> > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 ...many many more nodes > > =A0 =A0 =A0 </businesstype> > > </category> > > I don't see any problem with using * if you want to process all element > child nodes. > If you prefer you can name each element (type) explicitly e.g. in 2.0 > you can do > =A0 <xsl:template match=3D"businesstype"> > =A0 =A0<xsl:apply-templates select=3D"speciality, bigbox, internetonly"/> > =A0 </xsl:template> > or in 1.0 (and of course 2.0) you can do e.g. > =A0 <xsl:template match=3D"businesstype"> > =A0 =A0<xsl:apply-templates select=3D"speciality | bigbox | internetonly"= /> > =A0 </xsl:template> > You would need to test which version performs better with the XSLT > processor of your choice. > > -- > > =A0 =A0 =A0 =A0 Martin Honnen > =A0 =A0 =A0 =A0http://JavaScript.FAQTs.com/- Hide quoted text - > > - Show quoted text - Thanks for confirming and the tips. | ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
