Tyagi Ashish

Greenhorn
+ Follow
since Jul 12, 2009
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Tyagi Ashish

Hello there,
I have been following the spring tutorial (http://static.springsource.org/docs/Spring-MVC-step-by-step/part5.html).

When I tried to create database using following command

For Windows add:

'springapp/db/server.bat':

java -classpath ..\war\WEB-INF\lib\hsqldb.jar org.hsqldb.Server -database test

Now you can open a command window, change to the 'springapp/db' directory and start the database by running one of these startup scripts. I am getting following error.


C:\RSAWorkspace\spring\firstspring\db>java -classpath ..\war\WEB-INF\lib\hsqldb.jar org.hsqldb.Server -database test
[Server@6ca1c]: [Thread[main,5,main]]: checkRunning(false) entered
[Server@6ca1c]: [Thread[main,5,main]]: checkRunning(false) exited
[Server@6ca1c]: [Thread[main,5,main]]: Failed to set properties
java.lang.StringIndexOutOfBoundsException: String index out of range: -1
at java.lang.String.substring(Unknown Source)
at java.lang.String.substring(Unknown Source)
at org.hsqldb.server.ServerProperties.validateMultiProperty(Unknown Source)
at org.hsqldb.server.ServerProperties.validate(Unknown Source)
at org.hsqldb.server.Server.setProperties(Unknown Source)
at org.hsqldb.server.Server.main(Unknown Source)


Could anyone tell me what I am doing wrong. I am using latest hsqldb.jar file in my lib folder.
12 years ago
Please include include xerces.jar,wsexception.jar and jtidy.jar in your classpath
12 years ago
Do I need to import any special jar for execution of [1] splitting the output (for ex. xalan.jar, jaxp-api.jar).

Now I am having following exception after adding (xalan.jar)
javax.xml.transform.TransformerException: Can't transform a Source of type javax.xml.transform.stax.StAXSource
at org.apache.xalan.transformer.TransformerIdentityImpl.transform(Unknown Source)
at Demo2.main(Demo2.java:32)
Exception in thread "main" javax.xml.stream.XMLStreamException: A non-whitespace event found while calling nextTag.
at com.ibm.xml.xlxp.api.stax.msg.StAXMessageProvider.throwXMLStreamException(StAXMessageProvider.java:59)
at com.ibm.xml.xlxp.api.stax.XMLStreamReaderImpl.nextTag(XMLStreamReaderImpl.java:667)
at com.ibm.xml.xlxp.api.stax.XMLInputFactoryImpl$XMLStreamReaderProxy.nextTag(XMLInputFactoryImpl.java:197)
at Demo2.main(Demo2.java:28)
ok so here I have modified the code for debug prospective and got the following exception

Code:



Content of Input.xml:
<?xml version="1.0" encoding="iso-8859-1"?>
<import>
<dkoffer>Ashish</dkoffer>
<dkoffer>mohan</dkoffer>
<dkoffer>raj</dkoffer>
</import>

Exception:
The Source is dkoffer and the content is Ashish
Exception in thread "main" java.lang.IllegalStateException: XMLStreamReader must be in the START_DOCUMENT or START_ELEMENT state.
at javax.xml.transform.stax.StAXSource.<init>(Unknown Source)
at Demo.main(Demo.java:32)


Can you explain why it is not fetching the content of rest of the two element. Thanks !!!
I am honestly saying, the code is running without exception and it is creating file as well but those files are empty and I am not sure how to fix that. Could you guys check if I have to add some more line in the code or I would have to import any jar file
Infact my original requirement said split the xml file into N small files where you provide N at run time, please let me know if you have code for that. You can use any of the sample XML you want. Thank you so much
I am new with this thing but I have to implement this. I have tried with following XML as well but that is not working

<?xml version="1.0" encoding="UTF-8"?>
<statements>
<statement account="123">
Ashish
</statement>
<statement account="456">
Mohan
</statement>
</statements>


Could you please correct my code and provide the sample well-formed XML so that I can run and test that. I would really appreciate your help brother
Could you please help me How can I achieve that, thanks
Hello I am trying to break-up big xml into small, I am using StAX, but I am not able to write back the content to the new file. Program is creating empty file

Please find my code

import java.io.File;
import java.io.FileReader;
import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLStreamConstants;
import javax.xml.stream.XMLStreamReader;
import javax.xml.transform.OutputKeys;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.stax.StAXSource;
import javax.xml.transform.stream.StreamResult;

public class Demo {

public static void main(String[] args) throws Exception {
XMLInputFactory xif = XMLInputFactory.newInstance();
XMLStreamReader xsr = xif.createXMLStreamReader(new FileReader("input.xml"));
xsr.nextTag(); // Advance to statements element

TransformerFactory tf = TransformerFactory.newInstance();
Transformer t = tf.newTransformer();
while(xsr.nextTag() == XMLStreamConstants.START_ELEMENT) {
File file = new File("out/" + xsr.getAttributeValue(null, "account") + ".xml");
t.setOutputProperty(OutputKeys.INDENT, "yes");
t.transform(new StAXSource(xsr), new StreamResult(file));

}
}

}





the input file contain

<statements>
<statement account="123">
</statement>
<statement account="456">
</statement>
</statements>



Please help me as soon as possible