Rajendra Gangarde

Greenhorn
+ Follow
since Sep 10, 2004
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 Rajendra Gangarde

I am Validating xml file against xsd. xsd file is given by ibm
so I am using following code.But it is giving problem in xsd file itself.
But if try to validate the xml with same xsd by using online utility it works.It is giving following error.Does anyone faced the same problem?
Thanks in advance
Error:
DocumentBuilderFactory: org.apache.xerces.jaxp.DocumentBuilderFactoryImpl
error: InvalidRegex: Pattern value 'first|last|[-#]?[0-9]+' is not a valid regular expression. The reported error was: ''-' is an invalid character range. Write '\-'.'.
error: cvc-complex-type.3.2.2: Attribute 'handle' is not allowed to appear in element 'portletinstance'.
Root node: #comment


Code is given below:

package com.hsbc.bde.deployment;

import java.io.IOException;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.xml.sax.SAXException;

public class XMLValidator {

public static final void main(String[] args) {
String xmlFile = "test11.xml";

try {
XMLValidator XMLValidator = new XMLValidator(xmlFile);
}
catch (Exception e) {
System.out.println( e.getClass().getName() +": "+ e.getMessage() );
}
}

public XMLValidator(String xmlFile) throws ParserConfigurationException, SAXException, IOException {

DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
System.out.println("DocumentBuilderFactory: "+ factory.getClass().getName());

factory.setNamespaceAware(true);
factory.setValidating(true);
factory.setAttribute("http://java.sun.com/xml/jaxp/properties/schemaLanguage", "http://www.w3.org/2001/XMLSchema");

// Specify our own schema - this overrides the schemaLocation in the xml file
//factory.setAttribute("http://java.sun.com/xml/jaxp/properties/schemaSource", "file:./test.xsd");

DocumentBuilder builder = factory.newDocumentBuilder();
builder.setErrorHandler( new SimpleErrorHandler() );

Document document = builder.parse(xmlFile);
Node rootNode = document.getFirstChild();
System.out.println("Root node: "+ rootNode.getNodeName() );
}
}
17 years ago
I am executing java application from shell script. I want to return some value from application which will be used as status code by shell script.
How we should be able to do it?
17 years ago
Sorry, I mean to say I have to write shell script in linux,
Which will
1) detect JRE is installed.
2) then check that required libraries are installed
if not then displays error message or else continue application bundled as jar file.
Hope this makes my question more clear
17 years ago
I wanted to detect JRE from shell script.
Is there any way to do this?
17 years ago
I am not sure about this topic should be part of this form or not. But Still its related to java.
I have to write a shell script in java that will detect JRE and then start executing application bundled as jar file. Thanks in advance
17 years ago
Thanks everybody. I have tried using linked HashMap.But apart from maintaining insert order I want to groupp the element.
I am parsing no. of xml files having similar structure as below
e.g.
<request>
<portal>
<skin id />
<theme id/>
<webapp id>
<servlet id />
</webapp>
</portal>
</request>

and I have to generate a consolidated xml file from all the input xml files. (Request and portal is common to all files.)For this i am using Composite design pattern and storing elements in HashMap. Now the proble is the generated output xml file is displaying webapp, skinn and them for first xml, then next and so on. Now I wanted to group skin, theme,webapp from all files i.e. output xml will first display all skins then themes an so on. Can you please help me how to deal with this problem.
17 years ago
How can I retrive the elements in the HashMap(by using keyset), in the same order as they are inserted.
17 years ago