Thursday, September 1, 2011

No source code is available for type javax.xml.parsers.DocumentBuilderFactory

Hi,

I am new to Java and GWT. I am trying to parse a xml, which I have
written as stringbuilder.

1) I tried using XMLParser.parse(xmlstring); but it gave a
DOMException tat string is crossing max length. Is there any way to
work around this.

2) I used DocumentBuilderFactory ... the code is as follows. It gives
the error as

No source code is available for type
javax.xml.parsers.DocumentBuilderFactory - It is some sort of
Inheritance issue. But I am unaware of what exactly inherit name i
should be using. Please guide.

------------------------- code
---------------------------------------------------
edu.xml.gwt.ibm.tutorialDemo1.client;

import java.io.IOException;
import java.io.InputStream;
import java.io.StringReader;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;


import com.google.gwt.core.client.EntryPoint;
import org.w3c.dom.Document;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;

/**
* Entry point classes define <code>onModuleLoad()</code>.
*/
public class TutorialDemo1 implements EntryPoint {

xmlquery callquery = new xmlquery();
String xmlstring;
/**
* This is the entry point method.
*/
public void onModuleLoad() {

xmlstring = callquery.xmlget_capabilities();
System.out.println(xmlstring);

DocumentBuilderFactory factory =
DocumentBuilderFactory.newInstance();
InputSource inStream = new InputSource();
inStream.setCharacterStream(new StringReader(xmlstring));
//doc = builder.parse(new
ByteArrayInputStream(xml.getBytes("UTF-8")));
try {
DocumentBuilder builder = factory.newDocumentBuilder();
try {
Document doc = builder.parse(inStream);

System.out.println("");
} catch (SAXException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} catch (ParserConfigurationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
----------------------- xml string return function
-------------------------------------------------

public String xmlget_capabilities(){

StringBuilder xmlquery = new StringBuilder("") ;
xmlquery.append("<?xml version='1.0' encoding='UTF-8'?>"
+ "<GetCapabilities xmlns='http://www.opengis.net/sos/1.0>"
+ "<ows:AcceptVersions>"
+ "<ows:Version>1.0.0</ows:Version>"
+ "</ows:AcceptVersions>"
+ "<ows:Sections>"
+ "<ows:Section>OperationsMetadata</ows:Section>"
+ "<ows:Section>ServiceIdentification</ows:Section>"
+ "<ows:Section>ServiceProvider</ows:Section>"
+ "<ows:Section>Filter_Capabilities</ows:Section>"
+ "<ows:Section>Contents</ows:Section>"
+ "</ows:Sections>"
+ "</GetCapabilities>");

return xmlquery.toString();

}

---------------------------------------------------------------------------------------------------------------------------------

Thanks,
Vrushali

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.

No comments:

Post a Comment