Hello all,
I've a problem:
i've an xsl file that has a template that contains
the following:
<script type="text/javascript">
<![CDATA[
a long javascript with < > characters, like:
for(var i=0;i<xmlDataFunctions.length;i++) {
}
]]>>
</script>
Ok when this is transformed i get the following:
<script type="text/javascript">
a long javascript with < > characters, like:
for(var i=0;i<xmlDataFunctions.length;i++) {
}
</script>
But i dont want this, because javascript does not now < and >
So i used:
<script type="text/javascript"><xsl:text disable-output-escaping="yes"><![CDATA[
a long javascript with < > characters, like:
for(var i=0;i<xmlDataFunctions.length;i++) {
}
]]></xsl:text></script>
Ok now i get:
<script type="text/javascript">
a long javascript with < > characters, like:
for(var i=0;i<xmlDataFunctions.length;i++) {
}
</script>
But because it is all part of an web-application i want to
get valid xhtml. This is not valid.So what i want is this as output:
<script type="text/javascript">
<![CDATA[
a long javascript with < > characters, like:
for(var i=0;i<xmlDataFunctions.length;i++) {
}
]]>
</script>
How do i do that with xslt?? 8 12691
Tempore 18:12:59, die Friday 07 January 2005 AD, hinc in foro {comp.text.xml} scripsit Tjerk Wolterink <tj***@wolterinkwebdesign.com>: But because it is all part of an web-application i want to get valid xhtml. This is not valid.So what i want is this as output: <script type="text/javascript"> <![CDATA[ a long javascript with < > characters, like: for(var i=0;i<xmlDataFunctions.length;i++) { } ]]> </script>
Just specify 'cdata-section-elements' attribute
<xsl:output cdata-section-elements="script" method="xml"/>
regards,
--
Joris Gillis ( http://www.ticalc.org/cgi-bin/acct-v...i?userid=38041)
"Quot capita, tot sententiae" - Terentius , Phormio 454
Joris Gillis wrote: Tempore 18:12:59, die Friday 07 January 2005 AD, hinc in foro {comp.text.xml} scripsit Tjerk Wolterink <tj***@wolterinkwebdesign.com>:
But because it is all part of an web-application i want to get valid xhtml. This is not valid.So what i want is this as output: <script type="text/javascript"> <![CDATA[ a long javascript with < > characters, like: for(var i=0;i<xmlDataFunctions.length;i++) { } ]]> </script>
Just specify 'cdata-section-elements' attribute
<xsl:output cdata-section-elements="script" method="xml"/>
regards,
ok i understand, but now i want the output to be:
<script type="text/javascript">
//<![CDATA[
a long javascript with < > characters, like:
for(var i=0;i<xmlDataFunctions.length;i++) {
}
//]]>
</script>
Those // are javascript comments, these are neccesary because some old browsers
do support javascript but do not support xml, so i have to comment them out with //
..
How would you do that?
Tempore 11:05:57, die Saturday 08 January 2005 AD, hinc in foro {comp.text.xml} scripsit Tjerk Wolterink <tj***@wolterinkwebdesign.com>: <script type="text/javascript"> //<![CDATA[ a long javascript with < > characters, like: for(var i=0;i<xmlDataFunctions.length;i++) { } //]]> </script>
Those // are javascript comments, these are neccesary because some old browsers do support javascript but do not support xml, so i have to comment them out with //
How would you do that?
To the best of my knowledge, XSLT1.0 does not provide a way to create a CDATA section from only a part of a text node.
I'm not really convinced that there would ever be need of such output, but if you really need it and don't mind dirty hacks, you could use something like this:
<?xml version='1.0' encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html"/>
<xsl:template match="script">
<script type="text/javascript">
<![CDATA[
//<![CDATA[
a long javascript with < > characters, like:
for(var i=0;i<xmlDataFunctions.length;i++) {
}
//]]>
]]>
</script>
</xsl:template>
</xsl:stylesheet>
regards,
--
Joris Gillis ( http://www.ticalc.org/cgi-bin/acct-v...i?userid=38041)
Vincit omnia simplicitas
Keep it simple
> <script type="text/javascript"> //<![CDATA[ a long javascript with < > characters, like: for(var i=0;i<xmlDataFunctions.length;i++) { } //]]> </script>
How would you do that?
If the output type of your XSL is set to 'xml' (to produce xhtml) , I think this problem is literally unsolvable.
--
Joris Gillis ( http://www.ticalc.org/cgi-bin/acct-v...i?userid=38041)
Vincit omnia simplicitas
Keep it simple
Joris Gillis wrote: <script type="text/javascript"> //<![CDATA[ a long javascript with < > characters, like: for(var i=0;i<xmlDataFunctions.length;i++) { } //]]> </script>
How would you do that?
If the output type of your XSL is set to 'xml' (to produce xhtml) , I think this problem is literally unsolvable.
Thanks for your time, i already thought it was difficult to solve, but
i want both be xhtml-valid and cross-browser, those things collide.
On solution is to put the javascript in a separe js file and include it using <script src=""/>
But its a really page specific javascript so therefore i want to include it inline.
But anyways, thanks.
Tempore 11:49:41, die Saturday 08 January 2005 AD, hinc in foro {comp.text.xml} scripsit Joris Gillis <ro**@pandora.be>: <script type="text/javascript"> //<![CDATA[ a long javascript with < > characters, like: for(var i=0;i<xmlDataFunctions.length;i++) { } //]]> </script>
How would you do that?
If the output type of your XSL is set to 'xml' (to produce xhtml) , I think this problem is literally unsolvable.
Forget what I said, I was plain wrong...
This is a working - but rather ugly - solution:
<?xml version='1.0' encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml"/>
<xsl:template match="/">
<script type="text/javascript">
<xsl:text disable-output-escaping="yes">
<![CDATA[
//<![CDATA[
a long javascript with < > characters, like:
for(var i=0;i<xmlDataFunctions.length;i++) {
}
//]]>
]]>
</xsl:text>
</script>
</xsl:template>
</xsl:stylesheet>
--
Joris Gillis ( http://www.ticalc.org/cgi-bin/acct-v...i?userid=38041)
Vincit omnia simplicitas
Keep it simple
In article <op**************@news.pandora.be>,
"Joris Gillis" <ro**@pandora.be> wrote: To the best of my knowledge, XSLT1.0 does not provide a way to create a CDATA section from only a part of a text node.
I'm not really convinced that there would ever be need of such output,
There is no need when the output is subjected to proper XML processing.
Producing XHTML with XSLT and serving it as text/html without a
specialized Appendix C converter is a bad idea. Using inline style
sheets or scripts in such a situation is an even worse idea.
--
Henri Sivonen hs******@iki.fi http://iki.fi/hsivonen/
Mozilla Web Author FAQ: http://mozilla.org/docs/web-developer/faq.html
Tjerk Wolterink wrote: Hello all,
I've a problem:
i've an xsl file that has a template that contains the following:
<script type="text/javascript"> <![CDATA[
a long javascript with < > characters, like: for(var i=0;i<xmlDataFunctions.length;i++) { }
]]>> </script>
FAQ. http://www.ucc.ie/xml/#usecdata
///Peter
--
"The cat in the box is both a wave and a particle"
-- Terry Pratchett, introducing quantum physics in _The Authentic Cat_ This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Dimitre Novatchev |
last post by:
You seem to be unaware of the xslt processing which uses the built-in
rules in the absence of templates that match some selected node.
...
|
by: troppfigo |
last post by:
I have this example of xml
<?xml version="1.0"?>
<xml>
<!]>
</xml>
I want to extract the contained data from <body> tag using an xslt...
|
by: Simon Brooke |
last post by:
Here's my problem:
<xsl:template match="/category">
....
<script
type="text/javascript">
<!]>
</script>
....
</xsl:template>
|
by: Lals |
last post by:
Hi,
I am stuck in problem involving transformation where I want to put my
source contents as itself in the target XML
My input xml looks like
...
|
by: Max |
last post by:
Hello everyone!
Can anyone help me to convert the CDATA expression "CDATA ::= (Char* -
(Char* ']]>' Char*)" to Javascript Regular Expression?
...
|
by: Dariusz Tomoń |
last post by:
Hi,
I have got xml document with CDATA sections containing special characters
like links to images. All Iwant is to display the content withing...
|
by: andybdi |
last post by:
I am playing with a few xml feeds changing them into different formats
and merging them with others, and have found that when using cdata-...
|
by: satyajit123 |
last post by:
HI All,
I have a requirement which has an XML with CDATA content in it is to be passed through an XSL for transformation to HTML tags. The xml is...
|
by: dkyadav80 |
last post by:
Hi sir,
I'm new about xml, javascript. I have two selection field(html) first is city and second is state. the city and state values should be...
|
by: concettolabs |
last post by:
In today's business world, businesses are increasingly turning to PowerApps to develop custom business applications. PowerApps is a powerful tool...
|
by: teenabhardwaj |
last post by:
How would one discover a valid source for learning news, comfort, and help for engineering designs? Covering through piles of books takes a lot of...
|
by: CD Tom |
last post by:
This happens in runtime 2013 and 2016. When a report is run and then closed a toolbar shows up and the only way to get it to go away is to right...
|
by: CD Tom |
last post by:
This only shows up in access runtime. When a user select a report from my report menu when they close the report they get a menu I've called Add-ins...
|
by: jalbright99669 |
last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
|
by: antdb |
last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine
In the overall architecture, a new "hyper-convergence" concept was...
|
by: Matthew3360 |
last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
|
by: AndyPSV |
last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...
|
by: Arjunsri |
last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and...
| |