Embedding javascript with xslt generated html
hi,
I'm using xml/xslt with xdk to generate html with embedded javascript. The solution works except that I am having problem with proper inclusion of the javascript file. I uset this line:
<xsl:template match="/">
<head><title>Screener</title>
<!-- Javascript declarations -->
<script language="javascript1.2" src="./screener.js">
</script>
I have tested the xslt sheet via IE5 and msxml3 processor and it works fine including loading the javascript file.
Now using XDK and servlet it doesn't seem to retrieve the javascript file so all javascript function do not work.
I would appreciate any help.
thanks,
ted
null
hi brian,
All those files are in same directory i changed the .xsl file to be i am changing at the right place.
However, as backup i tried the following:
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="html"/>
<script language="javascript1.2">
<![CDATA[
<!--
var isNav4, isIE4;
if (parseInt(navigator.appVersion.charAt(0)) >= 4) {
isNav4 = (navigator.appName == "Netscape")? true:false
isIE4 = (navigator.appName.indexOf("Microsoft" != -1)) ? true:false
if (isNav4) { document.write("<B>It's a Navigator!</B>");}
else { document.write("It's an Explorer!");}
//== shared global variables
function _alert(e)
alert(e);
-->
]]>
</script>
and here is the html output:
<html>
<head>
<title>Screener</title>
<script language="javascript1.2">
<!--
var isNav4, isIE4;
if (parseInt(navigator.appVersion.charAt(0)) >= 4) {
isNav4 = (navigator.appName == "Netscape")? true:false
isIE4 = (navigator.appName.indexOf("Microsoft" != -1)) ? true:false
if (isNav4) { document.write("<B>It's a Navigator!</B>");}
else { document.write("It's an Explorer!");}
//== shared global variables
function _alert(e)
alert(e);
-->
</script>
</head>
So everything is being output correctly except for <!--; is there a way around this problem? If I leave out <!-- --> it works but
i was wondering if the present behavior is what's supposed to happen.
thanks,
ted
null
Similar Messages
-
Problem with portlets with XSLT generating dynamic portal compatible links
Hi,
We're using XSLT to transform XML data to HTML in a portlet. The problem is that
the XML contains headlines and we need to create links to the complete article,
which has to be displayed in the same portlet. How do I create a portal comaptible
link with XSLT? In the JSP you can use the netui tag library like:
<netui:anchor action="..">
link
<netui:parameter name="id" value="{id}"/>
</netui:anchor>
but how can I achieve this with XSLT? We tried generating the xsl with a jsp,
but this doesn't work since the data entered in the value attribute of the netui:parameter
tag will be encoded causing the XSL transformer to fail.
Is there an easy solution to this? Or can XSLT only be used with very simple content?
ArdWe're trying to display some news headlines, clicking a headline has to invoke
an action to display the complete article in the same portlet (using pageflow).
When displaying the articles we use XSLT like (this is a JSP generating XSLT):
<?xml version="1.0"?>
<%@ page contentType="text/x-xslt"%>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="html"/>
<xsl:template match="items">
<xsl:apply-templates select="item"/>
</xsl:template>
<xsl:template match="item">
<nobr>
<%-- ###### Here we need an action link, with the title as a request parameter
###### --%>
<xsl:value-of select="@title"/>
</nobr>
</xsl:template>
</xsl:stylesheet>
The XML is like:
<items>
<item title="some title"/>
<item title="some other title"/>
</items>
We need to generate a portal compatible link which invokes an action (show_details)
with the title of the article as a request parameter.
I know how to do this in a JSP, but since the data is in XML we like to do this
with XSLT.
Can you help?
Subbu Allamaraju <subbuATBeaDOTCom> wrote:
Could you elaborate (perhaps with some xsl snippet generated by jsp)
the
failures you were getting with xslt?
Subbu
Ard van der Scheer wrote:
Hi,
We're using XSLT to transform XML data to HTML in a portlet. The problemis that
the XML contains headlines and we need to create links to the completearticle,
which has to be displayed in the same portlet. How do I create a portalcomaptible
link with XSLT? In the JSP you can use the netui tag library like:
<netui:anchor action="..">
link
<netui:parameter name="id" value="{id}"/>
</netui:anchor>
but how can I achieve this with XSLT? We tried generating the xsl witha jsp,
but this doesn't work since the data entered in the value attributeof the netui:parameter
tag will be encoded causing the XSL transformer to fail.
Is there an easy solution to this? Or can XSLT only be used with verysimple content?
Ard -
How to display xslt generated html code?
Hi,
I transformed xml code into html code inside my action
class and put generated code into StringWriter, I
don't
know how I can display it on my jsp page?
I tried to turn generated html code into a big string,
then use bean:write to display it on jsp page, it just
does not work.
Has anyone done this kind of thing?
thankshi
Just put that String in JSP expression <%= String name %>
u will see it on browser
thanks
hithesh -
Help with embedding Javascript for Lightbox Photo Gallery in Muse!
Hi all:
I am fairly new to Muse and I have been having trouble finding relevant information for embedding Javascript in order to get a lightbox to work in Muse. Would anyone be able to walk me through embedding the Javascript for the Lightbox Photogallery for Picasa in Muse?
This is the code I want to use: Lightbox Photo Gallery and Slideshow for Picasa
And this is the look I am trying to accomplish within my Muse site: Cycling Around The World / January 2006 / Picasa Template by www.paulvanroekel.nl
Any help would be appreciate. Thanks much,
AlexisHi,
I have tried inserting the script that you have pasted above as HTML on my test site and it worked.
What happens is whenever you insert something as HTML, Muse by default creates a div tag and places the content within the div tag. What I have done differently is I have inserted the JS with in the <script> tag and it has inserted the Javascript in this manner,
I beleive that since this a browser re-direct script that you are using, you would like to place this in the head section and not in the body tag, however, that is certainly not possible using Muse as it does not allow access to the code it generates as a muse file.
You, can still export the pages as HTML and make the appropriate changes there before uploading to the server.
Hope that helps.
Regards, -
Hello,
I'm new to FlexPMD. I have just generated my firsts reports. I try to generate HTML reports.
I browse the documentation, this forum and the web and I find informations to :
- generate documentation with Hudson
- generate documentation with Maven
- generate documentation with XSLT pmd.xml -> html
Ok, I try to keep it simple. So I don't want to use Hudson.
I'm using ANT, and I currently don't want to install/learn Maven.
I'm using FlexUnit with ANT. And It's really simple to generate reports :
<junitreport todir="${report.flexunit.loc}">
<fileset dir="${report.flexunit.loc}">
<include name="TEST-*.xml" />
</fileset>
<report format="frames" todir="${report.flexunit.loc}/html" />
</junitreport>
I'm really new to FlexPMD, so I don't have currently a big knowledge, but it seems impossible to generate a HTML report just like junitreport. (1 line in an ANT task)
I test the XSLT transformation found on this forum (thread "XSLT pmd.xml -> html"). It's really cool. But it's seems difficult, for example, to extract the wrong code part and add it to the HTML page.
So, what is the simpler solution to generate HTML report just with FlexPMD/ANT ?
Thanks !Hello,
Currently you generate a PMD report with ANT like this :
<! -- define taskdef -->
< taskdef name="pmd" classname="com.adobe.ac.pmd.ant.FlexPmdAntTask" classpath="${build.pmd.loc}/flex-pmd-ant-task-${flexpmd.version}.jar">
< classpath>
< path refid="flexpmd.base" />
< pathelement location="${build.pmd.loc}/commons-lang-2.4.jar" />
< pathelement location="${build.pmd.loc}/flex-pmd-core-${flexpmd.version}.jar" />
< pathelement location="${build.pmd.loc}/flex-pmd-ruleset-api-${flexpmd.version}.jar" />
< pathelement location="${build.pmd.loc}/flex-pmd-ruleset-${flexpmd.version}.jar" />
< pathelement location="${build.pmd.loc}/plexus-utils-1.0.2.jar" />
< /classpath>
< /taskdef>
then generate XML report like this :
< pmd sourceDirectory="${src.loc}" outputDirectory="${report.loc}" ruleSet="${build.pmd.loc}/rules.xml"/>
The XML contains some file nodes :
< file name="/Users/user/workspace/AS3_UTILS/src/utils/align/gridAlignSpaceNumber.as">
< violation beginline="22" endline="22" begincolumn="0" endcolumn="27" rule="adobe.ac.pmd.rules.naming.TooShortVariable" ruleset="All Flex Rules" package="utils.align" class="gridAlignSpaceNumber.as" externalInfoUrl="" priority="5">This variable name is too short (3 characters minimum, but 1 actually). Detects when a field, local, or parameter has a very short name< /violation>
< /file>
The message is in the text node < violation>TEXT< /violation>
For me, we miss an important part of the message : the portion of the "bad" code.
It could be very usefull if PMD can generate something like this :
< file name="">
< violation beginline="" endline="" begincolumn="" endcolumn="" rule="" ruleset="" package="" class="gridAlignSpaceNumber.as" externalInfoUrl="" priority="">
< description>TEXT< /description>
< code><CDATA[MY CODE
MY CODE
MY CODE]>< /code>
< /violation>
< /file>
With this, we can generate "full" HTML report with XSLT transform easily.
I understand that it modify the standard XML schema of the output.
So, perharps it could be an option like this :
< pmd fullDescription="true" sourceDirectory="${src.loc}" outputDirectory="${report.loc}" ruleSet="${build.pmd.loc}/rules.xml"/>
What do you think ?
Thanks ! -
Using javascript to dynamically generate the html for a Spry table
I have some javascript which generates html code for a Spry
table which displays the content of a Spry data set. The problem is
that after I generate the html, Spry never fills in the values for
the table.
Here's what I'm doing:
Using a data set observer, check for onPostLoad and generate
the html code
Using innerHTML, stuff the code into the appropriate
<div>
Use regionName.updateContent() to update the region I just
created with the html code I generated
Interestingly, if I take the generated source for my page and
remove the data set observer, the Spry table displays correctly
with all the expected values. This suggests to me that my generated
html code is correct, but that there is some sort of timing issue
(i.e. Spry doesn't know about the new code I generated).
Any suggestions?jalperin wrote:
> Here's what I'm doing:
>
Using a data set observer, check for
onPostLoad and generate the html
> code
>
Using innerHTML, stuff the code into
the appropriate <div>
>
Use regionName.updateContent() to
update the region I just created
> with the html code I generated
>
> Interestingly, if I take the generated source for my
page and remove the data
> set observer, the Spry table displays correctly with all
the expected values.
> This suggests to me that my generated html code is
correct, but that there is
> some sort of timing issue (i.e. Spry doesn't know about
the new code I
> generated).
>
> Any suggestions?
I'd guess that it is a timing issue as well. I haven't looked
much at the dataset capability in Spry, but it may be that the
dataset "finds" all of the regions and code that it applies to
before the onPostLoad event is triggered. If that is the case, then
your generated code doesn't exist yet,and so the dataset thinks
that there is nothing for it to apply to.
Will the HTML that you generate change based upon the dataset
that is actually returned? I guess I'm looking for the reason why
the HTML is being generated when it could be in the page itself and
avoid this issue completely.
Danilo Celic
|
http://blog.extensioneering.com/
| WebAssist Extensioneer
| Adobe Community Expert -
In Flash CS4 a generated html with swf file won't play swf
Using Flash CS4 and having the Flash plug-in ver 10 on my PC, the generated html file will not play the swf in the browser.
I noticed that the active-x javascript is now included in the header as well as the javascript portion in the body tag.
But it won't play. I get the typical blank window in IE with the "X" in the upper left corner.
I don't have this problem with Flash CS3.
Any ideas what may be going on?
Thank you.I am having similar difficulty; mostly I am confused.
I want to open a flash video file in a frame within a webpage.
I have generated a Flash CS4 html and swf file. When loaded they play, but they play on a separate, full size web page, not in the frame where I want it.
I then generated FLV and F4V files but that doesn't work.
It appears that I need to insert the object and embed tags "for Flash Movies" in the html file.
Once I do that, do I go back to only putting in the html and swf files and create a link to the html file to bring up the video in the target frame?
What are the FLV files for? -
Handling events in javascript which are generated by embedded applet
I am having an tipical requirement , In my HTML page there is an embedded applet . This applet is going to generate custom events . I would like to handle that events in javascript which are generated from applet . I mean that javascript has to get a notification of the event that is generated from applet . I would appreciate if some one can send me the code .
Hi look at my post further down about 5-6 posts. It's called: "For your information. Very interesting." It talks about Netscapes Live Wire.
-
Jquery + json generate html buttons with condition
Hi all,
My need is to generate buttons with conditions described in json. Help me please, I’m newbie.
Here is my json code (it is valid, but does not work with html code below) :
"Caption": "Module caption",
"IconsDirectory": "C://Images/",
"Buttons": [
"Conditions": [
"ConditionText": "1 == 1",
"ButtonText": "Text1",
"Visible": true,
"Colors": {
"FontColor": "#FFFFFF",
"BGColor": "#00FF00"
"Size": {
"Width": 200,
"Height": 50
"Icon": {
"FileName": "Smile.png",
"Width": 16,
"Height": 16
"Url": {
"UrlAddress": "http://www.google.com",
"OpenNewWindow": true
"JavaScriptAction": {
"Text": "alert('ok');"
"ConditionText": "2 == 2",
"ButtonText": "Text2",
"Visible": true,
"Colors": {
"FontColor": "#FFFFFF",
"BGColor": "#00FF00"
"Size": {
"Width": 200,
"Height": 50
"Icon": {
"FileName": "Smile.png",
"Width": 16,
"Height": 16
"Url": {
"UrlAddress": "http://www.google.com",
"OpenNewWindow": true
"JavaScriptAction": {
"Text": "alert('ok');"
html code:
<html>
<head>
<title>SMButtons</title>
[removed][removed]
[removed]
//When document loaded.
$(document).ready(function(){
// Get data from file as JSON
$.getJSON('weekendtask.json', function(data) {
var buttons = data.Buttons;
$.each(buttons, function(key, val)
$('<li><input type="button" value="'+ val.ButtonText +'"/></li>').appendTo('#ulObj');
[removed]
</head>
<body>
<br>
<br>
<div>
<ul id='ulObj'>
<li>1</li>
<li>2</li>
<li>3</li>
</ul>
</div>
</body>
</html>
Also I would like to show here my working code (generating html buttons from json without condition).
json code (it works) :
"Caption": "Module caption",
"IconsDirectory": "C://Images/",
"Buttons": [
"TText": "google",
"JavaScriptAction": "alert('google')"
"TText": "microsoft",
"JavaScriptAction": "alert('microsoft')"
"TText": "yahoo",
"JavaScriptAction": "alert('yahoo')"
html code (it works) :
<html>
<head>
<title>SMButtons</title>
<script src="jquery/jquery-1.4.2.js"></script>
<script type="text/javascript">
//When document loaded.
$(document).ready(function(){
// Get data from file as JSON
$.getJSON('Module.json', function(data) {
// Set json data from file to variable 'persons'
var buttons = data.Buttons;
var icondir = data.IconsDirectory;
// For each item of variable person append to ul list
$.each(buttons, function(key, val)
//$("<li><input type='button' onClick='"+ val.Url +"' value='"+ val.Text +"'/></li>").appendTo('#aaa');
//$("<li><input type='button' style='"+ val.Style +"' onClick='"+ val.Url +"' value='"+ val.Text +"'/></li>").appendTo('#aaa');
//$("<li><input type='button' value='"+ val.TText +"'/></li>").appendTo('#bbb');
//style="height: 25px; width: 100px"
//$('<li><input type="button" onClick="'+ val.action +'" value="'+ val.Text +'"/></li>').appendTo('#aaa');
$('<li><input type="button" onClick="'+ val.JavaScriptAction +'" value="'+ val.TText +'"/></li>').appendTo('#ulObj');
//var knop = data.Knop;
// For each item of variable person append to ul list
//$.each(buttons, function(key, val)
//$("<li><input type='button' onClick='"+ val.Url +"' value='"+ val.Text +"'/></li>").appendTo('#aaa');
//$("<li><input type='button' style='"+ val.Style +"' onClick='"+ val.Url +"' value='"+ val.Text +"'/></li>").appendTo('#bbb');
//style="height: 25px; width: 100px"
//$('<li><input type="button" onClick="'+ val.action +'" value="'+ val.Text +'"/></li>').appendTo('#aaa');
//$('<li><input type="button" onClick="'+ val.action +'" value="'+ val.Text +'"/></li>').appendTo('#aaa');
</script>
</head>
<body>
<br>
<br>
<div>
<ul id='ulObj'>
<li>1</li>
</ul>
</div>
<br>
<div>
<ul id='aaa'>
<!--<li>1</li>-->
</ul>
</div>
<!--<button type="submit" style="height: 95px; width: 550px"> </button>-->
<!--background: url('img/submit_button.jpg'); background-position: center; background-repeat: no-repeat; background-color:Transparent;-->
<div>
<ul id='bbb'>
<!--<li><img src="img/submit_button.jpg"/></li>-->
<!--<li>Button caption</li>-->
</ul>
</div>
</body>
</html>What you are saying makes great sense. It's just the mechanics behind what you've said that I'm unclear about.
<p>
Are you saying to create another button within the same region with the same attributes/position, so they overlay each other? Then set the conditions on both buttons?
<p>
If I understand the above correctly, then how do I set the conditions? I guess I'm asking where do I place the SQL statement and how does the results relate to the button conditions?
<p>
Thanks for the help,
David -
Embedding Javascript and HTML nto Adobe Muse
I am trying to embed javascript for dynamic text into my Adobe Muse site but I can't seem to get it to work.
Here is my code:
HTML:
<span id="spanDate"></span>
Javascript:
<script type="text/javascript">
var months = ['January','February','March','April','May','June','July',
'August','September','October','November','December'];
var tomorrow = new Date();
tomorrow.setTime(tomorrow.getTime() + (1000*3600*24));
document.getElementById("spanDate").innerHTML = months[tomorrow.getMonth()] + " " + tomorrow.getDate()+ ", " + tomorrow.getFullYear();
</script>
I am placing the Javascript under metadata in the page properties. I tried on the individual page and on the master page. And I am placing the HTML with the Insert HTML option.
I can't seem to get the code to populate properly though. I tried the same code on a test site and it worked just fine.
Any and all advice is greatly appreciated!It seems you have some blank spaces at the end of each line in your javascript code. Try checking for that.
In an unrelated issue I found another error in your CSS file. In your moduleStyleSheets.css file on line 1253 you have an extra ; on the end.
border-bottom: 1px solid #eee;;
Should be:
border-bottom: 1px solid #eee; -
How to generate html-code using csv input with JSP or JAVA???
Hello,
I want to read out a .csv-file and generate html-code dynmically with JSP in an EP6 Application. The problem is, that the csv-file cant be located or openend.
BTW if every knows a good tutorial or weblog for this, please post the link.
Its located in a par-archive under:
/>dist>files
I tried various methods, in the doContent mehtod or with JSP. Everytime same result.
Here part of the code I tried in the doContent():
public class CSV extends AbstractPortalComponent
public void doContent(IPortalComponentRequest request, IPortalComponentResponse response)
String strWRoot = request.getWebResourcePath();
String contentCSV="", line="";
String linesep = System.getProperty("line.separator");
File fileLoadCSV = new File(strWRoot+"/files/ma_infosysteme.csv");
boolean exCSV = fileLoadCSV.exists();
boolean reCSV = fileLoadCSV.canRead();
int a=0;
if(exCSV&&reCSV){
response.write("ok");
try {
BufferedReader inputCSV = new BufferedReader(new FileReader(fileLoadCSV));
while((line=inputCSV.readLine())!=null){
contentCSV=contentCSVlinelinesep;
a++;
inputCSV.close();
catch(IOException ioex){
System.out.println("Fehler");
else {
response.write("not ok");
response.write("<br>Wroot: "+strWRoot);
response.write("<br>File: "+fileLoadCSV);
response.write("<br>exists: "+exCSV);
response.write("<br>read: "+reCSV);
response.write("<br>Input: "+contentCSV);
The Output is:
not ok
Wroot: /irj/portalapps/DHTML
File: \irj\portalapps\DHTML\files\ma_infosysteme.csv
exists: false
read: false
Input:
So thanks to everyone who can give me a good hint.
Bye.Without really looking too much into this it looks like the problem is with the way in which you are trying to open the file. I believe that when creating a File object you need to use a physical path. By using the getWebResourcePath() method you are retrieving the URL to this file and not the physical path name. There is another method (can't remember the exact name) called getPublicResourcePath() (or something similar) which will return the physical path to this file, i.e. c:\usr\sap\.....etc. If you try it this way it may well work
I hope this helps
D -
Access embedded reader with javascript
For a project I'm looking for a way to display pdf files within a webbrowser. I have IE8+ with acrobat reader available to me, so i can display any given pdf. But i would like to be able to change pages, jump to bookmarks with javascript functions in my html page.
So in other words: does acrobat reader have somesort of api through which i can access my document using javascript?Post the query in the forum for Acrobat SDK.
-
Hi all,
I am looking for a way and example of how to run javascript against an HTML file. My project is a web site test utility that can load HTML pages and submit forms, however some forms require executing javascript to set or validate various form fields. I've looked into the Rhino javascript engine, but I do not understand how to execute the javascript functions which change HTML form values. Can anyone give examples of how this can be done? Please let me know if I need to explain this further.
Thanks!Sorry the description of what I am doing is a bit vague. My java application is like a web crawler, no web browser involved, but it needs to behave like a web browser. The application will parse html and follow links found in anchor HTML tags. When my app encounters a form, it can build the target URL by parsing the form action, and all form elements such as the input, select and whatnot. The tricky part is when forms involve javascript that may alter values in form input fields, for example, hidden input fields. In this case, my app cannot simply build the target URL combining form field values. My application must execute any found javascript functions so that the correct values are placed in the form fields, then the true URL can be built. I investigated the Rhino javascript engine, which seems great for executing javascript methods, but I cannot find how to include form fields in the HTML which the javascript function may alter. I'm not set on using Rhino, just anything that works.
-
Ok..losing my mind here. Running on 11.2.0.2 AIX
I have an xslt to generate html document. Some of the html will be provided by an end-user... which I will embed into the xslt, to create one final template. Some problems I'm having:
- br tags... no matter what I try, can't seem to prevent the transform from outputting
<br></br>The issue is this is causing double line-breaks when rendered in a browser or email client (using this to generate html emails)
Example:
declare
l_xml xmltype;
l_html_part clob;
begin
l_xml := xmltype('<content>This is a test</content>');
SELECT XMLSerialize(document XMLtransform(l_xml , xmltype('<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" encoding="UTF-8" omit-xml-declaration="yes"/>
<xsl:template match="/">
<html><body>
<p><xsl:value-of select="content" /></p>
<blockquote>
Some text <br/>
on muliple <br/>
lines<br/>
here.
</blockquote>
</body>
</html>
</xsl:template>
</xsl:stylesheet>')) as clob) into l_html_part from dual;
p.l(l_html_part);
end;Generates the following:
<html><body><p>This is a test</p><blockquote>
Some text <br></br>
on muliple <br
</br>lines<br></br>
here.
</blockquote></body></html>I've tried changing the method output from html to xml... but to no avail.
Now given I'm accepting html input from end users to embed into my xslt (enabling end users to customize the html template), any other issues I should guard against? I plan on using a wysiwyg javascript editor on the front end, to tidy the html input as much as possible, so it's well-formed. However, dealing with entities, and URLs means I may have to scrub the html a little further?
For instance, URLs will sometimes contain & in the query string... and parameter values... one has to be escaped to & while the other URL encoded..
Thanks for any tips or advice.
Stephane
Edited by: pl_sequel on Feb 9, 2012 3:04 PM
Edited by: pl_sequel on Feb 9, 2012 3:05 PMThanks for that... I missed that keyword in the docs.
The embedding of the user supplied html will be done using regexp_replace most likely.
The design I am going with, is an html template stored in a clob, with various "merge tags" defined in the body.
for example:
<html>
<body>
<p>This is a test. Hi *|FIRSTNAME|*</p>
*|CONTENT|*
</body>
</html>User will supply the html:
<p>This is the user html content</p>I will then replace the *|CONTENT|* in the body with the user-supplied html:
<html>
<body>
<p>This is a test. Hi *|FIRSTNAME|*</p>
<p>This is the user html content</p>
</body>
</html>At this point, I now take the final html template, and turn it into an XSLT. Any remaining merge tags, get replaced with appropirate xsl:value-of statements as well..
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" />
<xsl:template match="/">
<html>
<body>
<p>This is a test. Hi <xsl:value-of select="FIRSTNAME" /></p>
<p>This is the user html content</p>
</body>
</html>
</xsl:template>
</xsl:stylesheet>I will then have the respective xml data transformed using this stylesheet.
Kinda creating a custom templating engine... to enable users to merge in custom data (which is already stored in the DB) and customize the template content. The final transformed html will be used to send as an html email. -
in OC4J,I write a XSLT as follows:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.1">
<xsl:strip-space elements="doc chapter section"/>
<xsl:output method="xml" encoding="GBK" indent="yes"/>
<xsl:template match="doc">
<html>
<script language="JavaScript">
for(i=0;i!=3;i++){ //!!!!!,it is "!="
alert("aa");
</script>
<body bgcolor="#f0d0a0" text="#202040">
<xsl:apply-templates/>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
the run a xml with this xsl is ok;but when I change the
JavaScript "1!=3" into "i<3",the new xsl is as following:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.1">
<xsl:strip-space elements="doc chapter section"/>
<xsl:output method="xml" encoding="GBK" indent="yes"/>
<xsl:template match="doc">
<html>
<script language="JavaScript">
for(i=0;i<3;i++){ //!!!!!,it is "<"
alert("aa");
</script>
<body bgcolor="#f0d0a0" text="#202040">
<xsl:apply-templates/>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
when I run with the same xml,it reports:
java.lang.NullPointerException at
org.apache.xalan.transformer.TransformerImpl.createResultContentH
andler(TransformerImpl.java:1059) at
org.apache.xalan.transformer.TransformerImpl.createResultContentH
andler(TransformerImpl.java:1000)
at org.apache.xalan.transformer.TransformerImpl.transform
(TransformerImpl.java:1115)
at com.evermind[Oracle9iAS (1.0.2.2) Containers for
J2EE].servlet.XSLServlet.service(XSLServlet.java:290)
at javax.servlet.http.HttpServlet.service
(HttpServlet.java:336)
at com.evermind[Oracle9iAS (1.0.2.2) Containers for
J2EE].server.http.HttpRequestHandler.processRequest
(HttpRequestHandler.java:647)
at com.evermind[Oracle9iAS (1.0.2.2) Containers for
J2EE].server.http.HttpRequestHandler.run
(HttpRequestHandler.java:189)
at com.evermind[Oracle9iAS (1.0.2.2) Containers for
J2EE].util.ThreadPoolThread.run(ThreadPoolThread.java:62).
how do I write the comparison literal "<"?You can escape the "<" symbols within the Javascript with <
for fairly simple/small sets of code. We're generating a good
bit of js and editing with all the escapes in place gets a bit
tedious. We're getting around this by escaping the entire block
with <xsl:text output-escaping="yes"><[CDATA[ immediately before
the <script> tag and ]]></xsl:text> after the </script> tag.
This works fairly well, albeit there are issues whent the js
needs to access xsl data, but that can usually be overcome by
placement.
rob.
Maybe you are looking for
-
Hi All I am working on Indesign CS4, please help i am working on spreads pages I have all spreads page are extract in and save a only one spread at every pages in indesign please help me and give me a javascript For exmpale : 2 and 3 is only one inde
-
How can I autoupdate my itunes library from the music added to my computer.
-
When will a camera raw plugin beavailable for the Nikon D810
I recently purchased a Nikon D810 but can not see the images when I download them to either Lightroom or Photoshop. I am told I need a new plug-in. When will onebe available?
-
Can't share a link in safari through email on ipad air
i am unable to share a link when I'm in safari using email in my iPad air. The email text box just disappears
-
My imessage won't send or recieve anything on my mac.
my ipod is fine, but my mac can't seem to get it together. i've tried turning it on and off, quitting the application, and restarting the entire computer but nothing works. suggestions?