Differences between value-of and apply-templates in XSLT
-
can someone explain to me the differences between those two functions? in the simple examples i've been doing, they seem interchangeable. and i read the MSDN xslt reference which shed some light, but not really. particularly, it says value-of will give me a string of the matched element. great. so that means if i have TESTING will give me "TESTING". as will which, if there is no template for "element" will use the default template, right? and the default template is basically just outputing the value of the tag? but msdn also says value-of should give me a concatenation of strings if the matched element has a substructure. so if i had 1 2 should give me "12", right? well, not when i tried it. or am i misunderstanding? anyway, that's just one question i had. the actual quote from msdn is "If the node returned is an element with substructure, returns the concatenated text nodes of that element's subtree with the markup removed." the real question is what's the difference between the two and what would you use them for?
-
can someone explain to me the differences between those two functions? in the simple examples i've been doing, they seem interchangeable. and i read the MSDN xslt reference which shed some light, but not really. particularly, it says value-of will give me a string of the matched element. great. so that means if i have TESTING will give me "TESTING". as will which, if there is no template for "element" will use the default template, right? and the default template is basically just outputing the value of the tag? but msdn also says value-of should give me a concatenation of strings if the matched element has a substructure. so if i had 1 2 should give me "12", right? well, not when i tried it. or am i misunderstanding? anyway, that's just one question i had. the actual quote from msdn is "If the node returned is an element with substructure, returns the concatenated text nodes of that element's subtree with the markup removed." the real question is what's the difference between the two and what would you use them for?
AFAIK, the docs are right about value-of, which is used to get a value from a node. apply templates is used to set a point at which the process of building a result will begin. They have different goals in mind, even if one can simulate the other in some circumstances. Christian No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002 C# will attract all comers, where VB is for IT Journalists and managers - Michael P Butler 05-12-2002 Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002
-
can someone explain to me the differences between those two functions? in the simple examples i've been doing, they seem interchangeable. and i read the MSDN xslt reference which shed some light, but not really. particularly, it says value-of will give me a string of the matched element. great. so that means if i have TESTING will give me "TESTING". as will which, if there is no template for "element" will use the default template, right? and the default template is basically just outputing the value of the tag? but msdn also says value-of should give me a concatenation of strings if the matched element has a substructure. so if i had 1 2 should give me "12", right? well, not when i tried it. or am i misunderstanding? anyway, that's just one question i had. the actual quote from msdn is "If the node returned is an element with substructure, returns the concatenated text nodes of that element's subtree with the markup removed." the real question is what's the difference between the two and what would you use them for?
If you are ever interested in obtaining better documentation on XSL than what you get from Microsoft, Michael Kay's XSLT Programmer's Reference is a really good book. It's definitely a reference, not a "how to" book, and will give you examples of the different ways in which you can use the various XSL elements. Sean Winstead
-
If you are ever interested in obtaining better documentation on XSL than what you get from Microsoft, Michael Kay's XSLT Programmer's Reference is a really good book. It's definitely a reference, not a "how to" book, and will give you examples of the different ways in which you can use the various XSL elements. Sean Winstead
Although it's worth mentioning that he has an unreasonable hatred of all things from Redmond, that is indeed an excellent book and my main XSLT reference. Christian No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
C# will attract all comers, where VB is for IT Journalists and managers - Michael P Butler 05-12-2002
Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002