XSL with Javascript issue when using XslTransform.
-
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 "
-
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 "
hi, replace "<" with "<;". 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.)
-
hi, replace "<" with "<;". 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.)
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.
-
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.
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**<**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.) -
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**<**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.) -
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 "
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."
-
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**<**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.)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."
-
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."
that's better solution. thx Philip! Never forget: "Stay kul and happy" (I.A.)