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. Javascript in xsl

Javascript in xsl

Scheduled Pinned Locked Moved XML / XSL
xmljavajavascripthtmldata-structures
4 Posts 2 Posters 0 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
    Ashvish
    wrote on last edited by
    #1

    Hi All, I would like to load a java script array dynamically inside xsl. Suppose I have the following xml <srsource> <individualsr> <srid>srid1</srid> <srothervalue>srothervalue1</srothervalue> </individualsr> <individualsr> <srid>srid2</srid> <srothervalue>srothervalue2</srothervalue> </individualsr> </srsource> What I want to do is populate a javascript array during the xsl transformation so that I get an array like the one below when the html page is loaded. test['srid1'] = 'srothervalue1' test['srid2'] = 'srothervalue2' and so on.. Could anyone tell me how the above piece of code can be included inside xsl:for-each? Thanks Ashvish

    L 1 Reply Last reply
    0
    • A Ashvish

      Hi All, I would like to load a java script array dynamically inside xsl. Suppose I have the following xml <srsource> <individualsr> <srid>srid1</srid> <srothervalue>srothervalue1</srothervalue> </individualsr> <individualsr> <srid>srid2</srid> <srothervalue>srothervalue2</srothervalue> </individualsr> </srsource> What I want to do is populate a javascript array during the xsl transformation so that I get an array like the one below when the html page is loaded. test['srid1'] = 'srothervalue1' test['srid2'] = 'srothervalue2' and so on.. Could anyone tell me how the above piece of code can be included inside xsl:for-each? Thanks Ashvish

      L Offline
      L Offline
      led mike
      wrote on last edited by
      #2

      Ashvish wrote:

      What I want to do is populate a javascript array during the xsl transformation so that I get an array like the one below when the html page is loaded.

      Ashvish wrote:

      Could anyone tell me how the above piece of code can be included inside xsl:for-each?

      Not sure I understand your question. I mean whatever you put inside the xsl:for-each is output into the result so like:

      <xsl:for-each select="*/individualsr">
        test['<xsl:value-of select="./srid"/>'] = '<xsl:value-of select="./srothervalue"/>';
      </xsl:for-each>

      led mike

      A 1 Reply Last reply
      0
      • L led mike

        Ashvish wrote:

        What I want to do is populate a javascript array during the xsl transformation so that I get an array like the one below when the html page is loaded.

        Ashvish wrote:

        Could anyone tell me how the above piece of code can be included inside xsl:for-each?

        Not sure I understand your question. I mean whatever you put inside the xsl:for-each is output into the result so like:

        <xsl:for-each select="*/individualsr">
          test['<xsl:value-of select="./srid"/>'] = '<xsl:value-of select="./srothervalue"/>';
        </xsl:for-each>

        led mike

        A Offline
        A Offline
        Ashvish
        wrote on last edited by
        #3

        Thanks for the reply. What I am really trying to do is something like <xsl:variable name="user" select="Login/UserInfo/UserName"/> <SCRIPT language="JavaScript"> <![CDATA[ ... rowA = new Object() rowA.data1 = ']]><xsl:value-of select="$user" /><![CDATA[' rowA.data2 = 'needs' rowA.data3 = 'help' myTable.append_row(rowA) ... ]]> </SCRIPT> This works in Mozilla but not in IE. What could be the reason?

        L 1 Reply Last reply
        0
        • A Ashvish

          Thanks for the reply. What I am really trying to do is something like <xsl:variable name="user" select="Login/UserInfo/UserName"/> <SCRIPT language="JavaScript"> <![CDATA[ ... rowA = new Object() rowA.data1 = ']]><xsl:value-of select="$user" /><![CDATA[' rowA.data2 = 'needs' rowA.data3 = 'help' myTable.append_row(rowA) ... ]]> </SCRIPT> This works in Mozilla but not in IE. What could be the reason?

          L Offline
          L Offline
          led mike
          wrote on last edited by
          #4

          I don't know if you post got messed up or what but it doesn't make any sense.

          led mike

          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