XML :: Setting Stylesheet Ref When Outputting File Using SAXTransformerFactory

Sep 27, 2012

I am using SAXTransformerFactory to output an XML file but can't figure out how to output the stylesheet setting, for example:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE ectd:ectd SYSTEM "util/dtd/ich-ectd-3-2.dtd">
<?xml-stylesheet type="text/xsl" href="util/style/ectd-2-0.xsl"?>

I am using the following code to get the first two lines, I just can't see how to output the third line above.

SAXTransformerFactory mTransformerFactory = (SAXTransformerFactory) SAXTransformerFactory.newInstance();
TransformerHandler handler = mTransformerFactory.newTransformerHandler();
Transformer mTransformer = handler.getTransformer();

mTransformer.setOutputProperty(OutputKeys.VERSION, "1.0");
mTransformer.setOutputProperty(OutputKeys.ENCODING, IBF_UtilXML.XML_ENCODING_UTF8);
mTransformer.setOutputProperty(OutputKeys.DOCTYPE_SYSTEM, "util/dtd/ich-ectd-3-2.dtd");

I believe I found an example using a DOM approach but I would much prefer using SAX.

<?xml-stylesheet type="text/xsl" href="util/style/ectd-2-0.xsl"?>

View Replies


ADVERTISEMENT

Reading / Outputting A Text File With Modified Content

Feb 15, 2014

This is sort of like the last problem I had but it's all about the formatting at the end. I have a file that reads something like:

Name
a bunch of text here
and perhaps a second
or even a third line

I need to output this as:

Name; "a bunch of text here and perhaps a second or even a third line"

Right now I find 'Name' and it outputs:

Namea bunch of text here and perhaps a second or even a third line

How would I add ";" and quotes in the middle? I can imagine that I may need to find name, then skip to the next line and just add name manually as the variable output of the search string.

This is where I am now

public static void main(String[] args) {
boolean output=false;
String name="";
String junk="CHAMBERS";
TextIO.putln("Search for a name");
name = TextIO.getln();
TextIO.readFile("doc.txt");

[Code] .....

So I'm almost there, but those dange double Names are killing me. I tried to add a bit of code where:

if (line.indexOf(name) >= 0){}

View Replies View Related

Servlets :: CSS Stylesheet Will Not Work With JSP Files

Feb 11, 2014

Why I can't get an external style sheet work work when using JSP files? Putting a link in the doc head like I would for an HTML or PHP file does not work. The style sheet is in the exact same directory as the JSP files and I cannot get it to work. I think I have tried about everything that has been suggested on the web with no luck.

If I create an HTML doc in the same directory as the JSP files, and add the below line in the document head, it works fine. Doing the same thing with a JSP file does nothing.

<link rel="stylesheet" type="text/css" href="style.css">

View Replies View Related

JavaFX 2.0 :: Set Default Stylesheet For User Control

Jan 26, 2015

How can I set the default stylesheet for a user control that I have created? I want to make the control available for anyone to use and I want it to use a stylesheet by default without the user of the control having to do anything. I also want it to be possible for the user of the control to override the definitions set on the default stylesheet if he wants to.

View Replies View Related

Reading Data From A File And Setting It To Array

Jun 5, 2014

I can read the data to a monitor perfectly. But, I'm having problem reading data from an external file into an array of class objects. Here's my attempt at writing the method:

private void openFile()
//This method asks the user to enter a file name(including the file extension) and then
//Sets the data to an array of Product type {
String fileName, storeName="", emptyLine1="", emptyLine2="", name="", productName="";
int demandRate=0;
double setupCost=0.0, unitCost=0.0, inventoryCost=0, sellingPrice=0;
Scanner inputStream = null;

[code]...

View Replies View Related

Swing/AWT/SWT :: Setting File Name For JFileChooser Save Dialog

Aug 9, 2001

I am wondering how to do the following:when a user clicks on a save menu item, a save JFileChooser pops up. I would like to have a default file name set in the FileName box on the chooser, similar to what applications like Microsft word has. Right now, no file name will appear until the user has selected a file.I also need to know how to get the text from this box in the case that the user enters a new file name (the getSelection function is not useful here because the user will not have selected an existing file.)

View Replies View Related

Variable Outputting 0 Instead Of Value

Oct 24, 2014

I have code that displays 3 game scores the series total and average. For some reason game 3 outputs 0 and game 1 and 2 output correctly. I don't see anything different that game 3 is doing that game 1 and game 2 aren't so I'm not sure what the problem is.

java file

package com.valenciaprogrammers.mybowlingscores;
import java.text.DateFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
public class BowlingScores implements Comparable<BowlingScores>{
private long id;

[Code] .....

View Replies View Related

If Else / Switch Not Outputting Correctly

Jan 27, 2014

Trying to learn switch statements. Can't figure out what I am doing wrong.

java Code:

import java.util.Scanner;
public class Ok1 {
public static void main(String args[]) {
Scanner input = new Scanner(System.in);

[code]...
When I run, it makes me enter letter = null and it wont output correctly.

View Replies View Related

Why Is Loop Outputting Line Twice

Oct 29, 2014

I have a loop and I was wondering why it is outputting my line twice. Here is the code:

while (x != -1) // closes the program if the user enters -1 for x
{
System.out.println("Which jar would you like to access? Please select a number between 1 and 3. Press -1 to exit.");
x = scan.nextInt();
ourpantry.Selection(x); // tells our pantry class what number the user selected
while ((response != "continue")) // loop continues until user gives a valid response

[Code] ....

This results in the Output:

Would you like to spread jam? Y or N.
Would you like to spread jam? Y or N.

View Replies View Related

Outputting Calendar On Console

Oct 14, 2014

I created a calendar program so when the user enters a day number and a year it would show the calendar for the year . My issue was that I could not get the numbers to line up neatly and how they should look . Also if its not to much trouble I would like to know how to turn this in to a loop .

import java.util.Scanner;
public class Calendar {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.println("Enter a Year");
int Year = scanner.nextInt();

[Code] .....

View Replies View Related

Outputting 2 Classes - ToString Method

Apr 22, 2014

My current assignment involves me outputting these 2 classes. Yet I'm not really sure in what manner I should go about doing this. I have tried creating a separate class and outputting my toString methods there but for some reason I am getting an error. .

The error message is thus;

Exception in thread "main" java.lang.NullPointerException
at Vehicle.toString(Vehicle.java:91)
at Run.main(Run.java:17)
 Process completed.

import java.util.Calendar;
public class HireContract {
String reference;
Calendar startDate = null;
Calendar endDate = null;
Vehicle vehicle = null;;
String customerRef;
double rate;

[Code] .....

View Replies View Related

User Input - Outputting To Excel Document

Mar 30, 2014

I am currently working towards taking input from the user and storing it in an excel document. However how can I test to make sure that I am trying to save it to an empty cell. Is there some type of method that will check to make sure the cell is empty, otherwise how can this be done?

View Replies View Related

Double Data Type Outputting To Exponent?

Nov 9, 2014

I was struggling to use BufferedReader to extract some data and then perform some calculations and then have the results as outputs.

I haven't quite solved that issue but in order to progress, I hard coded some values into my application and proceeded with the actual calculation loops etc.

Currently, the value out put from one of my calculations is given as:

1.1704926E7

How can I make the console show it in a natural way. I've performed the calculation manually and it should be 11704926.5 I don't want to lose that .5!

View Replies View Related

Comparing Two Array List And Outputting Difference

May 12, 2014

I'm having a bit of trouble outputting the difference between two array list

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.PrintWriter;
import java.util.ArrayList;
public static void main(String[] args) throws Exception {

[Code] ....

This prints out something like

Test1
Test1
Test2
Test2
Test2
Test3
Test3
Test3
Test4
Test4
Test5
Test5
Test6
Test6
Test6

Ideally, it's suppose to print out only Test2, Test3, Test6.. I've tried different combinations of loops and equals() but I never get the correct output.

View Replies View Related

Program Outputting Null Into Validation Statement - Runtime Error

Oct 17, 2014

I am Having trouble with my program to validate. It is outputting null into the validation statement then it brings back a run-time error to that validation Statement for the String.

public String validateData ()
{
if (nm == null)nm = "Error! Must enter at least one character";
else nm = name;
return name;
}//end validation method

Why is this happening, and then once that is completed, why is the validation Sentence in tests Scores not able to validate. I traced it back to out put "Error, a number between 1<100".

public void validateTests ()
{
String testschange;
if (test1 < 0 || test1 > 100) {
testschange = " You have entered an invalid number, between 1-100. Please restart!";
testschange = Integer.toString( test1 ) ;

[Code] .....

View Replies View Related

Taking Range Of Names In Array And Outputting Them Alphabetically - OutOfBoundsException

Apr 24, 2014

At the moment I am studying it and the problem is Taking a range of names in an array and outputting them alphabetically, But for some reason I get an outOfBoundsException. And its starting to get to me. How to put the code in

import java.util.Scanner;
import java.util.Arrays;

public class lab241 {
public static void main(String[] args) {
Scanner kb= new Scanner(System.in);
String[ ] names = new String[4];

names[0]= ("Horatio");
names[1]= ("Anatoly");
names[3]= ("Evelyn");
names[4]= ("Anna");
Arrays.sort(names);
for(String N: names){

System.out.println(N);

View Replies View Related

Setting X And Y For String

Feb 15, 2014

I have been learning java and studying Swing but now i have a problem, i want to set x and y coordinates for this

Java Code:

JLabel jlbWorld = new JLabel("You have spawned"); mh_sh_highlight_all('java');

But how (I have searched internet for answers but all of them have JPanel)

View Replies View Related

Setting A String Using If

Oct 23, 2014

Here are two codes that I am using but I have one that just doesn't work for some reason and the other does. Encode doesn't work. I don't need the Character.isAlphabetic for encode but not sure what I can use with 'if' to set the String encodedString.

Java Code:

private String prepareString(String plainText)
{
String preparedString = "";
for(int i = 0 ; i < plainText.length();i++)
if(Character.isAlphabetic(plainText.charAt(i)))
{
preparedString = preparedString+Character.toUpperCase(plainText.charAt(i));

[code]....

View Replies View Related

Setting A Drive Label

Sep 22, 2014

I have been playing around with a snippet I wrote to get the Label on a drive (below). It works fine for me (though I will take any constructive criticism). My question is whether the is a way to set the drive label, purely with Java. I know I could call command line, or even resort to using the Windows API

import java.util.List;
import java.io.File;
import java.util.Arrays;

[Code]....

View Replies View Related

Error Setting Value For JSpinner

Apr 19, 2014

I'm using a jSpinner Number model:

Here's my code:

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
int qty2, total, payment, change;
String title;

[code]....

I tried using this since the jSpinner's minimum value is 1.. (I want it to reset the jSpinner after updating the database):

jSpinner1.setValue(new Integer(1));

But gives me an error:

Exception in thread "AWT-EventQueue-0" java.lang.ArrayIndexOutOfBoundsException: -1
at java.util.Vector.elementData(Vector.java:730)
at java.util.Vector.elementAt(Vector.java:473)
at javax.swing.table.DefaultTableModel.getValueAt(DefaultTableModel.java:649)
at shop.jSpinner1StateChanged(shop.java:267)
at shop.access$100(shop.java:22)
at shop$3.stateChanged(shop.java:145)
at javax.swing.JSpinner.fireStateChanged(JSpinner.java:457)

View Replies View Related

Setting Background Of JScrollPane?

Aug 19, 2014

My program's tree:

JFrame{
JPanel(That MenuBar at the top)
JPanel(That panel at center with table){
JScrollPane{
JTable
}
}
}

I want to add my custom image to that grey space right there. I guess it is a JScrollPane, because I added that orange background on JPanel that contains it. But when I add this code to my custom class of JScrollPane:

@Override
public void paintComponent(Graphics g) {
super.paintComponent(g);
if(background == null){
background = new ImageIcon(ClassLoader.getSystemResource("tableBg.png")).getImage();
}
g.drawImage(background, 0, 0, null);
}

The result is the same, no changes.

Then I read some documentation. I found this method:

scrollPane.getViewport().setBackground(Color c);

It works, but it accepts only color and I want to add image. Is there any way to do that? Do I need to subclass JViewport and use paintComponent ? If yes, then how to make getViewport() method return my custom subclassed version?

View Replies View Related

Setting Values In PDF Field?

Dec 12, 2014

I have a PDF file and I have a text file that contains this data. It has the name of a PDF field along with a database table column name.

Text file: pdfFieldEmployee=Employee; pdfFieldStartDate=StartDate; pdfFieldSalary=Salary; pdfFieldExempt=Exempt

I also have this hash map that contains the database table column names along with their corresponding values:

Employee, Don Parker
StartDate, 5/6/2000
Salary, $55000
Exempt, N

How would I read through the text file and the hash map and at the same time do this:

if the pdf field is equal to pdfFieldEmployee, then set pdfFieldEmployee equal to Don Parker.
if the pdf field is equal to pdfFieldStartDate, then set pdfFieldStartDate equal to 5/6/2000.

and so on and so on. I would prefer to do this with a loop because I think it would take less code than writing a bunch of if statements.

View Replies View Related

Getting And Setting Frame Name From Another Class

Aug 7, 2014

package com.simbaorka101.te.gui;

import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.ScrollPaneConstants;
import javax.swing.event.DocumentListener;

[code]....

This is my frame class, now I want to be able to change the name of the frame, and get the name with frame.getName() in another class. But I'm not sure how to do this, i tried making a new frame in that class but i feel it's just another frame and not the one i made, also tried something like

public JFrame getFrame(){
this.getFrame();
}

and few variations but it was wrong.

View Replies View Related

What Does Setting Object Equal To Another Do

Mar 5, 2014

I've seen this done in code:

For example:

Java Code: BufferedImageOp op = new ConvolveOp() mh_sh_highlight_all('java');

What does this mean? Is it creating an object of convolveOP for the BufferedImage class?

What does it mean when you set an object from one class equal to another?

View Replies View Related

JSP :: Getting And Setting Bean Property With Tag

May 11, 2014

Will it make any difference if I put the last line of code inside the useBean tag ?

<jsp:useBean id="person" class="foo.Person" scope="page" >
<jsp:setProperty name="person" property="name" value="Fred" />
</jsp:useBean>
<jsp:getProperty name="person" property="name" />

It gives me the same output though....

View Replies View Related

Setting Image As Background?

Jan 9, 2015

This is my code and it works! But how/where do I set a background image for it to appear as the background of my calculator? The code I have for it is this -

window.setContentPane(new JLabel(new ImageIcon("C:UsersComputerDownloadschristm as1.jpg")));

My code is below.

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
/**
* Program using SWING components to create a Christmas themed Calculator.
*/
public class ChristmasCalculator implements ActionListener

[code]....

View Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved