XML :: How To Give Java Document Schema For XPath Queries
Feb 5, 2013
javax.xml.parsers.DocumentBuilder can build a document from a single stream which is the XML file. However, I can't find any way to also give it a schema file.
Is there a way to do this so that my XPath queries can perform type aware queries and return typed data?
We presently use dom4j/jaxen and it does this fine but I figure we should switch to the standard Java runtime if this has been added.
A method in Java returns a schema. In .net, we use DataTable to get the data from the schema. How to write the following code in Java:
/* Result r = method(); r.DataSchema; */ using (DataTable tbl = new DataTable()) { using (MemoryStream ms = new MemoryStream()) using (StreamWriter sr = new StreamWriter(ms))
Lately I've been working with JDBC and writing queries in some Java programs. I've noticed that I keep experimenting with where I place my blocks of querying code. I've tried creating a private method in the class where the query is used, I've created utility classes where I can call the query when needed, and sometimes I've just put it in a localized block of code where I need to. Also, most often these queries are one-shot queries where I need to pull the data to populate a JTable.
In short, this has made me realize that I don't have a solid practice for organizing my queries in Java. So my question is "Is there a practice for organizing query code?".
My current calculator (currently available on my site) launches your default webbrowser with the CalculatorHistory file allowing you to print through your browser, but I been working on self contain the html page in a the JEditorPane which is great it does what i want, so I started working on the printing side and I am stuck...
The code I have was from a example (modified) but when I run the code I get the following error:
Exception in thread "main" java.lang.IllegalArgumentException: services must be non-null and non-empty at javax.print.ServiceUI.printDialog(Unknown Source) at gcclinux.co.uk.PrintReport.main(PrintReport.java:28)
The Line 28 equals to PrintService service = ServiceUI.printDialog(null, 200, 200,printService, defaultService, flavor, pras);
I need to generate the word document dynamically using java code, included the necessary jar files, No compliation issue, but During run time am getting this error: Could not initialize class org.openxmlformats.schemas.wordprocessingml.x2006. main.CTDocume .using all these jar files: POI-3.6.jar, POI_3.9.jar, Poi-ooxml-3.5,Poi-ooxml-3.6,Poi-ooxml-3.7,Poi-ooxml-3.9,Poi-ooxml-schemas-3.6,Poi-ooxml-schemas-3.9.jar. using the XWPFdocument class. when my cursor get into that line XWPFDocument doc = new XWPFDocument(); getting the above error.
Consider in a Document if a String " Hello" is Encoded and stored as "XYZAB"
I want to search the text on document for a word "Hello" and Replace the word with "HelloWorld"
The Program will encrypt the word "Hello" and Search the file then return the encrypted code as "XYZAB" Found
Now i have to replace the word "Hello" with "HelloWorld" in encrypted form so that the Letter "XYZABEFGHI" is replace in the place of Hello where "World" is encoded as "EFGHI"
Now the Problem is If there is more number of occurrence of the word "Helloworld" exist in the file... How can i Replace only one particular occurrence What can be done to select the particular occurrence.
I have attached my java program for Encryption along with this mail for your ease of use.
I am trying to parse a XML string into `org.w3c.dom.Document` object.
I have looked at solutions provided [here](xml - How to convert String to DOM Document object in java? - Stack Overflow), [here](How to create a XML object from String in Java? - Stack Overflow) and a few other blogs that give a variation of the same solution. But the `Document` object's #Document variable is always null and nothing gets parsed.
Here is the XML
XMLMappingValidator v = new XMLMappingValidator("<?xml version="1.0" encoding="utf-8"?> " + "<mapping> " + "<container> " + "<source-container>c:stem.csv</source-container>
[Code] ....
When I call **v.getXML().toString()** I get `[#document: null]`
Clearly, the parse is failing. But I don't understand why.
I've been googling information on how to print a pdf in java, and it seems that the java print api is used more for printing from a swing app. What I'm needing to do is send a pdf document to the printer upon user request. I would like my app to work as follows - User selects pdf to be printed- Program determines pages to be printed and deducts amount from user account- If sufficient money, program sends job to printer automatically without popping up the print screen.- If printed successfully, then program tells user it was printed. I'm able to figure out the rest of the pieces, in regards to user input and determining pages of the pdf, except I don't see how I will be able to print the pdf.
But all that I get is junk characters spread across 15 or so pages, for a pdf file that simply says "Hello World". I can open the pdf file on my computer, and print it ok, but when using the above code, it just prints out junk. How I might need to format or setup the pdf so that I can print it correctly. My program could be run on any number of Linux systems, with a multitude of printer types.
I am trying to parse a XML string into `org.w3c.dom.Document` object.
I have looked at solutions provided [here](xml - How to convert String to DOM Document object in java? - Stack Overflow), [here](How to create a XML object from String in Java? - Stack Overflow) and a few other blogs that give a variation of the same solution. But the `Document` object's #Document variable is always null and nothing gets parsed.
Here is the XML
Java Code:
XMLMappingValidator v = new XMLMappingValidator("<?xml version="1.0" encoding="utf-8"?> " + "<mapping> " + "<container> " + "<source-container>c:stem.csv</source-container>
[Code] .....
When I call Java Code: **v.getXML().toString()** mh_sh_highlight_all('java');
I get Java Code: `[#document: null]` mh_sh_highlight_all('java');
Clearly, the parse is failing. But I don't understand why.
I am looking to develop a program that does the following:
User selects Microsoft Excel xlsx, xlsm files.Program copies worksheets, userforms and modules from a template excel file into the user files.Program changes the XML schema of the files..I am looking for MAC compatibility too. Is Java suitable for this exact requirements I am asking?
I need to create dynamic Layouts that are created from java source code, using JAXB. As FXML does not have a schema, this gets me in trouble.
Scene Builder cannot be used for dynamic Layouts, but if there really is no schema I could use, maybe someone knows how Scene Builder generates the fxml files.
Ok so I know how to import a csv using java. What I'm curious about doing is importing a csv using file chooser, reading the data, sorting the data out by certain parameters, and then outputting a count of each parameter I chose. Say for example I have columns 1,2 and 3. Column 1 has the name, column 2 has the percentage, column 3 has an o'clock time. I want to use queries to sort through the parameters and have a count of each parameter I choose...
I am new to JSTL and JSP & I am running 2 seperate SQL queries from a java/jsp program and I need to display the results from both queries on one JSP page output.Currently I have java code that passes the 2 queries to a method along with passing the jsp files to output the query results
- the method dispatches the results to these 2 JSP pages using JSTL tags in hope for separate output results:
I need to have a way to display these 2 outputs into 1 jsp page: - currently one just overwrites the other.I also tried using the jstl core <c: tags in 2 separate methods on the same jsp page but the <c: tags just resulted in overwriting one another - The queries run and display fine except I cannot get them both to display correctly.using jstl and jsp for displaying multiple queries on the same page.example: the jsp file that runs the queries:
We currently have an application which uses JDBC to connect to the backend database (DB version - 11.2.0.3 ). The application uses a properties file in which the password for the db schema is hardcoded in plain text format. Due to security restrictions we have been asked to make sure the password is encrypted in the file and no direct access is made to the schema using the plain text password. Best options we can use to make this password encrypted both at Oracle DB side and Java side.
I have a question about query execution strategy ...
Scenario: let's suppose I've to query a table with a query like
SELECT F1, F2, F3 FROM MYTABLE WHERE F1 = ? AND F2 = ? AND F3 = ?.
I need to execute this query changing parameters' actual values in a combinatorial way, until a combination gives back at least one row or all combinations are unsuccessfully tried. For instance, I may have this sequence of values:
(V1,V2,V3); (V1,V2,""); (V1,"",V3); (V1,"","");
where V1, V2, V3 may by string values and V1 is always present, not null, and not blank in each combination.
A first strategy may be to prepare the statement, clear the parameters each time I execute the query, until stop condition is met.
I wonder if may be more efficient transform the query into
SELECT F1, F2, F3 FROM MYTABLE WHERE F1 = V1
and cycling over the cursor and, for each cursor row, verify if the returned tuple (F1,F2,F3) matches the combination (V1x,V2x,V3x). When at least 1 rows matches, or all combination are done, I'll exit iteration.
I am looking for java codes to generate a word document based on a word template, basically, I have a word template created and in my local path, the template has a proper format with some fields which will be filled in after java codes ran. The java codes will fetch one record from a table, and open the word template and then fill the fields in the word template, and created a new word document and save it in another folder.
I found this example: [URL] which is similar except it uses xml template instead of word template, how to make it work to change the template from xml to word (docx) template?
I have one problem regarding Running Multiple queries parallely and storing results in resultsets . I have multiple queries but I need to executing all at a time without having to wait for one query to complete execution and then run another as there are 2 queries say query1 takes 10 mins and hence query2 should also start simultaneously and not wait for query 1 for completion.
String query1="select * from knowledge_rep"; String query2="select * from events"; ResultSet rs=null; PreparedStatement ps =con.prepareStatement(query1); rs=ps.executeQuery(); ps =con.prepareStatement(query2); rs1=ps.executeQuery();
[Code] ....
The above one is time consuming and second implementation using branch i wont be able to resolve it to result set using execute batch. Considering there are multiple select queries and the number of queries to be executed are dynamic and unknown and all the data from the queries are needed. Any leads to perform all these by running multiple threads simantaneously.
My friends and me are trying to make online Test taking system. We got a very basic doubt.
We have developed classes and relationship between classes for example : Online Test Taking system will have admin and student class. And Admin will have list of students.. etc.
But question troubled me was: if we use database to store all data for example student details then I can perform all sorts of operations writing sql query and store result in some other database then what is the need of "ArrayList<Student> field in Admin".??
Question is: We can put everything in database and manipulate using database(sql) functions to manipulate it.Then what is the need of Arraylist of anything which is just used to store object details for example student details....??
i've worked with java for 1 month, i'm designing some practices at Netbeans IDE. my problem is i tried to make a single colorful interface using panels, adding colors and i want to know if i exist a way to give a color to the JFrame (i tried to use the background color option but this didn't work).
I have just started to work on Java EE and I am not able to put the refrence of css and javascript in jsp page.
My senario is below: I have created script file inside myJavaScript Folder like Web Container-> myJavaScript ->Home.js. Similarlly for css:Web Container-> myCss ->Home.css.
My Jsp page palced inside Like: Web Container-> Home ->Home.jsp.
How to give the reference of js and css file in my Home.jsp page.