Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. XML / XSL
  4. Differences between value-of and apply-templates in XSLT

Differences between value-of and apply-templates in XSLT

Scheduled Pinned Locked Moved XML / XSL
questionhtmlwpftestingbeta-testing
4 Posts 3 Posters 3 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Alfred Taylor
    wrote on last edited by
    #1

    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?

    C S 2 Replies Last reply
    0
    • A Alfred Taylor

      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?

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      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

      1 Reply Last reply
      0
      • A Alfred Taylor

        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?

        S Offline
        S Offline
        surehand
        wrote on last edited by
        #3

        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

        C 1 Reply Last reply
        0
        • S surehand

          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

          C Offline
          C Offline
          Christian Graus
          wrote on last edited by
          #4

          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

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups