• Visitors can check out the Forum FAQ by clicking this link. You have to register before you can post: click the REGISTER link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. View our Forum Privacy Policy.
  • Want to receive the latest contracting news and advice straight to your inbox? Sign up to the ContractorUK newsletter here. Every sign up will also be entered into a draw to WIN £100 Amazon vouchers!

Xsl

Collapse
X
  •  
  • Filter
  • Time
  • Show
Clear All
new posts

    #31
    Yes you can. Variable declared in a for-each loop take on the value at each iteration.

    Also parameters take on the value using <xsl:with-param> and can be used as variables.

    Suggest you understand what XSL(T) is. It is not C or Visual Basic. It's a template matching language for transforming XML.


    It's like slagging off ANSI SQL for not having loops, if, variables and cursors. You don't need that tulip if you understand SQL and have the correct mindset.
    First Law of Contracting: Only the strong survive

    Comment


      #32
      I needed a counter and accumulators for totals, wtf was the guy who made it thinking: okay he created loops, okay he created variable elements, okay he has got powerful evaluation engine that allows to add/substract etc.. and then he did not allow to assign new value to existing variable, WTF?

      Just think about it for a moment:

      1) you add loops
      2) you add element called variable
      3) you allow add things to vars

      But you don't allow to save it easily, FFS!!!

      Its not the same as ANSI SQL - there are no loops it it, no vars I think too - but when you add both and ignore fact that you need to assign back to var its beyond retarded!

      It seems to me that XSL was created by a bunch of people who, albeit smart, are totally out of touch with reality, IMO it would have been better if they did not create it at all, at least it would not confuse people, ffs.

      Comment


        #33
        Why not use XSLT sum() function and only aggregate the data required using XPath.

        Again, you have the WRONG mindset for XSLT.
        First Law of Contracting: Only the strong survive

        Comment


          #34
          Look, if you include loops and variables and evaluation engine, then you must be retarded not to allow assigning new value to vars.

          I run searches and see lots of people asking these simple questions and no good answers - either that XSL is a functional language, not procedural (well, stop using for each loops then ffs), or some really bad workaround that even I (and I don't have crazy taste for elegant code) hate.

          Why won't I use sum function? Because I process XML document row by row and prefer to keep total on the go, why can't I do it if XSL already offers variables, loops, ability to add stuff to variables... but not save into vars!.

          A load of crap this is - no wonder few people use it.

          Comment


            #35
            "This tutorial will demonstrate the programming features of XSLT. XSLT is different from conventional programming languages because XSLT is based on template rules which specify how XML documents should be processed. Although conventional programming languages are often sequential, template rules can be based in any order because XSLT is a declarative language. The stylesheet declares what output should be produced when a pattern in the XML document is matched."

            It is used widely and quite successfully by those that understand how to use it.

            HTH

            PS. Buy XSLT Cookbook http://www.oreilly.com/catalog/xsltckbk/

            That shows you can do pretty much anything in XSLT without those obsolete things called "variables" you rave about.
            Last edited by _V_; 30 August 2006, 17:00.
            First Law of Contracting: Only the strong survive

            Comment


              #36
              I have this book - its bad, especially when it talks about Xpath. Why bad? Because they spend 99% of time talking about obvious stuff, but spend very little time about hard things.

              I state categorically that if some language, functional or not, supports such things as: loops, variables, eval engine, then disallowing to assign new value to variable is totally unacceptable. If they did not support any of these (like ANSI SQL), then it would be okay in theory, but in practice result in vendor specific support for these necessary in day to day life elements.

              I never had to use cursors in SQL - but I treasure ability to use variables and loops because its a very effective way to solve problems without horrendous SQL.

              Comment


                #37
                Stick with VB then.
                First Law of Contracting: Only the strong survive

                Comment


                  #38
                  Its unsafe to let users write and execute VB. XSL offers safe interpetation, but it sucks badly - whoever created it clearly had warped mind and never talked to real world programmers who have to solve real world problems.

                  Comment


                    #39
                    LOL - no else for IFs!!!!!

                    Comment


                      #40
                      PHP Code:
                      <xsl:choose>
                      .........
                      <
                      xsl:otherwise
                      Get it in your HEAD - XSLT is not a imperative programming language.

                      Functional programming is very different from imperative programming. The most significant differences stem from the fact that functional programming avoids side effects, which are used in imperative programming to implement state and I/O. Pure functional programming disallows side effects completely. Disallowing side effects provides for referential transparency, which makes it easier to verify, optimize, and parallelize programs, and easier to write automated tools to perform those tasks.
                      XSLT is a functional programming language like Haskell or Scheme, and unlike C or Fortran. Thus it has no loops and no mutable variables. Instead, you must replace these constructs with recursion and parameters
                      You really don't understand computer science do you?
                      Last edited by _V_; 30 August 2006, 18:02.
                      First Law of Contracting: Only the strong survive

                      Comment

                      Working...
                      X