Both xsl:for-each
and xsl:template
are used to retrieve nodes from xml in an xsl stylesheet. But what is the fundamental difference between them? Please guide me. Thanks in advance.
相关问题
- XML - XSLT - document() function inside count() fu
- Google Test - generate values for template class i
- Template Specialization for Private Types
- zero length variadic expansion of ill-formed call
- Move product meta to the description tab in WooCom
相关文章
- How to use doMC under Windows or alternative paral
- Getting foreach() and ggplot2 to get along
- C++ Template specialization to provide extra membe
- SwiftUI automatically scroll to bottom in ScrollVi
- xslt localization
- C++: How to use unnamed template parameters in cla
- Templates, Function Pointers and C++0x
- foreach changes in PHP7
One use of
for-each
I haven't seen mentioned: you can use it to switch the context node to another document. I've used it to transform data XML to a HTML input form. The template that matched a data field contained a for-each that selected a single node: thexs:element
in the XSD that described the data field to transform.Using the description in the XSD one data field could be transformed to a radio button group, a drop down box, or a plain and simple text input. Without
for-each
I couldn't walk through the two documents at the same time.In general, I prefer matching templates. I find that it corresponds to the notion of a single transform applied at once better than for-each-ing this node, then the next, then the one after that, etc.. But that's a personal preference, of course.