250 - New
11 years ago
Use the -c option to include the config file
<renderers>
<renderer mime="application/pdf">
<fonts>
<!-- automatically detect operating system installed fonts -->
<auto-detect/>
</fonts>
</renderer>
</renderers>
//without XSLT:Add the stylesheet if using XSLT-XML.
transformer = factory.newTransformer();
...
Source src = new StreamSource(new File("src/currency.fo"));
//with XSLT
Source xslt = new StreamSource(new File("src/name2fo.xsl"));
transformer = factory.newTransformer(xslt);
...
Source src = new StreamSource(new File("src/name.xml"));
// Step 1: Construct a FopFactory
// (reuse if you plan to render multiple documents!)
FopFactory fopFactory = FopFactory.newInstance();
// Step 2: Set up output stream.
// Note: Using BufferedOutputStream for performance reasons (helpful with FileOutputStreams).
OutputStream out = null;
try {
out = new BufferedOutputStream(new FileOutputStream(new File("src/currency.rtf")));
Fop fop;
fop = fopFactory.newFop(MimeConstants.MIME_RTF, out);
// Step 4: Setup JAXP using identity transformer
TransformerFactory factory = TransformerFactory.newInstance();
Transformer transformer; // identity transformer
//without XSLT:
transformer = factory.newTransformer();
//with XSLT:
//Source xslt = new StreamSource(new File("src/name2fo.xsl"));
//transformer = factory.newTransformer(xslt);
// Step 5: Setup input and output for XSLT transformation
// Setup input stream
//without XSLT
Source src = new StreamSource(new File("src/currency.fo"));
//with XSLT
//Source src = new StreamSource(new File("src/name.xml"));
// Resulting SAX events (the generated FO) must be piped through to FOP
SAXResult res = new SAXResult(fop.getDefaultHandler());
// Step 6: Start XSLT transformation and FOP processing
transformer.transform(src, res);
} catch (FileNotFoundException ex) {
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
} catch (FOPException ex) {
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
} catch (TransformerConfigurationException ex) {
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
} finally {
//Clean-up
if (out != null) {
out.close();
}
}
#!/bin/bash #$1 is name of out param, $2 is name of out param func () { local loc=8 local diff=9 local same=10 eval "$1=$diff" eval "$2=$same" } loc=7 func out same echo "loc = $loc" #loc = 7 echo "out = $out" #out = 9 echo "same = $same" #same =
<html>
<head>
<title>Submit Events, Handlers and Prototypes</title>
<script type="text/javascript">
function submitFromScript() {
//There is no event object, but 'this' points to the form.
alert("Submitted by calling submit from a script: this = " + this);
//call the original, if it has been set.
if (this.submitPrototype) this.submitPrototype();
}
function submitFromSubmitButton(event) {
alert("Submitted by clicking a submit button in a form");
}
function submitFromWindowSubmitButton(event) {
alert("Submitted by clicking a submit button in a form, caught by window event");
}
function submitFromHandler(event) {
alert("Submitted by clicking submit button and overriding the submit handler for the form");
if (this.submitHandler) this.submitHandler();
}
// Function to change the content of t2
function modifyText(event) {
var t2 = document.getElementById("t2");
alert("modify t2: " + t2);
t2.firstChild.nodeValue = "three";
}
// Function to add event listener to t
function load() {
alert("load")
HTMLFormElement.prototype.submitPrototype = HTMLFormElement.prototype.submit;
HTMLFormElement.prototype.submit = submitFromScript;
var el = document.getElementById("frmPost");
el.submitHandler = el.submit;
el.submit = submitFromHandler;
el.addEventListener("submit", submitFromSubmitButton, false);
el.addEventListener("submit", modifyText, false);
}
window.addEventListener("load", load, false);
</script>
</head>
<body>
<form id="frmPost">
<input type="button" onClick="document.getElementById('frmPost').submit();" value="Submit by Script">
<input type="submit" value="Submit Button">
</form>
<table id="t">
<tr><td id="t1">one</td></tr>
<tr><td id="t2">two</td></tr>
</table>
</body>
</html>
function $(id) {
return window.document.getElementById(id);
}
Jaxer.Dir.resolve(Jaxer.Dir.combine(Jaxer.request.documentRoot, "blog/posts"));
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Write Blog</title>
<script src="lib/prototype/prototype.js" runat="server" type="text/javascript">
</script>
<script src="lib/showdown/showdown.js" runat="server" type="text/javascript">
</script>
<script runat="client" type="text/javascript">
function $(id) {
return window.document.getElementById(id);
}
function onSubmit(evt) {
var newPost = $("txaPostText").value;
if (newPost.length == 0) {
alert("You haven't entered anything.");
}
else {
if (save(newPost)) {
//add the new post
formatPost(newPost);
$("txaPostText").clear();
}
else {
alert("An error occurred. Couldn't save your post.");
}
}
//stop the form from submitting
evt.preventDefault();
$("txaPostText").focus();
}
function onLoad(){
$('frmPost').addEventListener('submit', onSubmit, false);
}
if (window.addEventListener) {
window.addEventListener("load", onLoad, false);
}
</script>
<script runat="server" type="text/javascript">
function serverLoad(){
//create the main posts <DIV>
var posts_div = document.createElement('div');
posts_div.id = 'posts';
document.body.appendChild(posts_div);
var path = Jaxer.Dir.resolve(Jaxer.Dir.combine(Jaxer.request.documentRoot, "blog/posts"));
if (!Jaxer.Dir.exists(path)) {
formatPost("Path does not exist: " + path);
return;
}
var dir = new Jaxer.Dir(path);
var files = dir.readDir().map(function(file){
var post = Jaxer.File.read(Jaxer.Dir.combine(dir.path, file.leaf));
formatPost(post);
});
}
window.addEventListener("serverload", serverLoad, false);
var formatPost = (function(showdown){
return function(content){
var post_div = document.createElement('div');
Element.extend(post_div);
post_div.innerHTML = showdown.makeHtml(content);
// insert new post in the main div
$('posts').appendChild(post_div);
}
})(new Showdown.converter());
function save(text){
try {
var path = Jaxer.Dir.resolve(Jaxer.Dir.combine(Jaxer.request.documentRoot, "blog/posts"));
Jaxer.Log.info(path);
var dir = new Jaxer.Dir(path);
//get the last post number
var lastFileNo = (dir.readDir()).length;
path = Jaxer.Dir.resolve(Jaxer.Dir.combine(dir.path, (lastFileNo + 1) + ".txt"));
Jaxer.Log.info(path);
Jaxer.File.write(path, text);
return true;
}
catch (e) {
Jaxer.Log.error(e);
return false;
}
}
save.proxy = true;
</script>
</head>
<body>
<h1>The Blog Page that Writes Files</h1>
<form id="frmPost" action="">
<textarea rows="10" cols="40" id="txaPostText"></textarea>
<input id="btnPost" type="submit" value="Submit Post"/>
</form>
</body>
</html>
Installing this Plugin via Aptana or Eclipse
1. From the Help menu, select Install New Software... to open an Install pop-up window.
2. In the Work with: text box of the Install window, type the URL http://update15.aptana.org/jaxer/25739/ for the update site, and hit the Enter key.
3. In the populated table below, check the box next to the name of the plug-in, and click the Next button.
4. Click the Next button to go to the license page.
5. Choose the option to accept the terms of the license agreement, and click the Finish button.
//------------------------------------------------------//
// Here's the code to determine the number of columns //
// in the ResultSet. //
//------------------------------------------------------//
Statement st = conn.createStatement();
ResultSet rs = st.executeQuery("SELECT * from Customer");
ResultSetMetaData rsmd = rs.getMetaData();
int numCols = rsmd.getColumnCount();
This can also be used to retrieve a column name.