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. XSL with Javascript issue when using XslTransform.

XSL with Javascript issue when using XslTransform.

Scheduled Pinned Locked Moved XML / XSL
xmlcsharpjavajavascripthtml
8 Posts 3 Posters 2 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.
  • B Offline
    B Offline
    Bart Man
    wrote on last edited by
    #1

    Greetings, I have a xsl file which transforms my xml file into a html page, and when I use it as a style sheet for my xml data it works fine. But when I use XslTransform called from a c# application it doesn't transform the file correctly it replaces my java script "<" symbol with "<" symbol. I have this code in a "

    D P 2 Replies Last reply
    0
    • B Bart Man

      Greetings, I have a xsl file which transforms my xml file into a html page, and when I use it as a style sheet for my xml data it works fine. But when I use XslTransform called from a c# application it doesn't transform the file correctly it replaces my java script "<" symbol with "<" symbol. I have this code in a "

      D Offline
      D Offline
      DavidNohejl
      wrote on last edited by
      #2

      hi, replace "<" with "&lt;". Yes, in JS. It will render/transform (?) correctly for browser. Than it should be fine. Also, you should (or even must, I am not sure) call XslTransform constructor that take XmlResolver as a parametr. (I don't know if it's really needed bt other constructors are obsolete ;)) best regards, David 'DNH' Nohejl Never forget: "Stay kul and happy" (I.A.)

      B 1 Reply Last reply
      0
      • D DavidNohejl

        hi, replace "<" with "&lt;". Yes, in JS. It will render/transform (?) correctly for browser. Than it should be fine. Also, you should (or even must, I am not sure) call XslTransform constructor that take XmlResolver as a parametr. (I don't know if it's really needed bt other constructors are obsolete ;)) best regards, David 'DNH' Nohejl Never forget: "Stay kul and happy" (I.A.)

        B Offline
        B Offline
        Bart Man
        wrote on last edited by
        #3

        Thanks for the reply, It still didn't work, it just left the &.l.t.; (kept formating it as <) in the javascript code. I saw a code blurb where they suggested commenting out the " //<![CDATA[ function test() { // Note, in this example the < has "." between them to keep the formating, since the forum kept reformating it as "<":) for(int index=0;index&.l.t.;10;index++) { ... Do something here. } } //]]>; ... ... It doesn't make any sense why this isn't working.

        D 1 Reply Last reply
        0
        • B Bart Man

          Thanks for the reply, It still didn't work, it just left the &.l.t.; (kept formating it as <) in the javascript code. I saw a code blurb where they suggested commenting out the " //<![CDATA[ function test() { // Note, in this example the < has "." between them to keep the formating, since the forum kept reformating it as "<":) for(int index=0;index&.l.t.;10;index++) { ... Do something here. } } //]]>; ... ... It doesn't make any sense why this isn't working.

          D Offline
          D Offline
          DavidNohejl
          wrote on last edited by
          #4

          hi, belive me, it works ;) maybe remove <![CDATA]> ?I am working on something similar and it is working! here is (simplified) my code: // xslt file <script language="JavaScript"> function ShowSelect(o) { var x2 = document.getElementsByTagName('div'); for(i=0;i**&lt;**x2.length;i++) { /* do stg*/ } } </script> </head> <body> // c# class calling XslTransform try { XslTransform xt = new XslTransform(); xt.Load(StylesheetURL); xt.Transform(SourceURL,ResultURL,**new XmlUrlResolver()**); } catch(Exception ex) { /* TODO */ throw; } What I missed? This is definitely working in my app. I can't send you my original code cuz my boss wouldn't be happy about it ;) David Never forget: "Stay kul and happy" (I.A.)

          B P 2 Replies Last reply
          0
          • D DavidNohejl

            hi, belive me, it works ;) maybe remove <![CDATA]> ?I am working on something similar and it is working! here is (simplified) my code: // xslt file <script language="JavaScript"> function ShowSelect(o) { var x2 = document.getElementsByTagName('div'); for(i=0;i**&lt;**x2.length;i++) { /* do stg*/ } } </script> </head> <body> // c# class calling XslTransform try { XslTransform xt = new XslTransform(); xt.Load(StylesheetURL); xt.Transform(SourceURL,ResultURL,**new XmlUrlResolver()**); } catch(Exception ex) { /* TODO */ throw; } What I missed? This is definitely working in my app. I can't send you my original code cuz my boss wouldn't be happy about it ;) David Never forget: "Stay kul and happy" (I.A.)

            B Offline
            B Offline
            Bart Man
            wrote on last edited by
            #5

            Thanks David! Your C# snippet worked great! Maybe it was because I was using the obsolete constructors or something. :) Thanks again!!

            1 Reply Last reply
            0
            • B Bart Man

              Greetings, I have a xsl file which transforms my xml file into a html page, and when I use it as a style sheet for my xml data it works fine. But when I use XslTransform called from a c# application it doesn't transform the file correctly it replaces my java script "<" symbol with "<" symbol. I have this code in a "

              P Offline
              P Offline
              Philip Fitzsimons
              wrote on last edited by
              #6

              the reason it does not work is that your html is not valid.... you don't have to escape < if you have specificied the out as html and the document root is html. your code does not work as I suspect your "html" tag is in upper case! http://www.w3.org/TR/xslt#section-HTML-Output-Method[^]


              "When the only tool you have is a hammer, a sore thumb you will have."

              D 1 Reply Last reply
              0
              • D DavidNohejl

                hi, belive me, it works ;) maybe remove <![CDATA]> ?I am working on something similar and it is working! here is (simplified) my code: // xslt file <script language="JavaScript"> function ShowSelect(o) { var x2 = document.getElementsByTagName('div'); for(i=0;i**&lt;**x2.length;i++) { /* do stg*/ } } </script> </head> <body> // c# class calling XslTransform try { XslTransform xt = new XslTransform(); xt.Load(StylesheetURL); xt.Transform(SourceURL,ResultURL,**new XmlUrlResolver()**); } catch(Exception ex) { /* TODO */ throw; } What I missed? This is definitely working in my app. I can't send you my original code cuz my boss wouldn't be happy about it ;) David Never forget: "Stay kul and happy" (I.A.)

                P Offline
                P Offline
                Philip Fitzsimons
                wrote on last edited by
                #7

                see http://www.codeproject.com/script/comments/forums.asp?forumid=3421&select=984122&msg=984122#xx984122xx[^]


                "When the only tool you have is a hammer, a sore thumb you will have."

                1 Reply Last reply
                0
                • P Philip Fitzsimons

                  the reason it does not work is that your html is not valid.... you don't have to escape < if you have specificied the out as html and the document root is html. your code does not work as I suspect your "html" tag is in upper case! http://www.w3.org/TR/xslt#section-HTML-Output-Method[^]


                  "When the only tool you have is a hammer, a sore thumb you will have."

                  D Offline
                  D Offline
                  DavidNohejl
                  wrote on last edited by
                  #8

                  that's better solution. thx Philip! Never forget: "Stay kul and happy" (I.A.)

                  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