I am trying to parse a XML file with JAXP.
Now what's happening to me ..that ..... the XML file is having some DTD which specifies a site DTD definition .... <!DOCTYPE jasperReport PUBLIC "//JasperReports//DTD Report Design//EN" "http://jasperreports.s ourceforge.net/dtds/jasperreport.dt d">
So right now Connection refused error is coming.
I know why it's coming .... But I want to put off the DTD parsing how could i do that.
One more thing if a DTD is of site then having no net connection validation can't be done ...????
What should be validation code for that .....
Debasis Jana.
7 4170
I am trying to parse a XML file with JAXP.
Now what's happening to me ..that ..... the XML file is having some DTD which specifies a site DTD definition .... <!DOCTYPE jasperReport PUBLIC "//JasperReports//DTD Report Design//EN" "http://jasperreports.s ourceforge.net/dtds/jasperreport.dt d">
So right now Connection refused error is coming.
I know why it's coming .... But I want to put off the DTD parsing how could i do that.
One more thing if a DTD is of site then having no net connection validation can't be done ...????
What should be validation code for that .....
Debasis Jana.
Turn off validation when you create the DocumentBuilder Factory. - factory.setValidating(false)
As for your second question, the answer is too complicated to type here :). It involves creating your own Resolver class to serve the dtd from your machine instead of the parser having to connect to the internet.
- talonx
Turn off validation when you create the DocumentBuilder Factory. - factory.setValidating(false)
As for your second question, the answer is too complicated to type here :). It involves creating your own Resolver class to serve the dtd from your machine instead of the parser having to connect to the internet.
- talonx
Thanks for your reply!
I am now having this code ... -
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
-
factory.setValidating(false);
-
DocumentBuilder jrxml = factory.newDocumentBuilder();
-
FileInputStream is = new FileInputStream(file);
-
Document jrxml_doc = jrxml.parse(is);
-
Still the error is coming.
What should I do?
Debasis Jana.
Thanks for your reply!
I am now having this code ... -
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
-
factory.setValidating(false);
-
DocumentBuilder jrxml = factory.newDocumentBuilder();
-
FileInputStream is = new FileInputStream(file);
-
Document jrxml_doc = jrxml.parse(is);
-
Still the error is coming.
What should I do?
Debasis Jana.
Which error is coming?
JosAH 11,448
Recognized Expert MVP
Thanks for your reply!
I am now having this code ... -
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
-
factory.setValidating(false);
-
DocumentBuilder jrxml = factory.newDocumentBuilder();
-
FileInputStream is = new FileInputStream(file);
-
Document jrxml_doc = jrxml.parse(is);
-
Still the error is coming.
What should I do?
Debasis Jana.
If you had read the API documentation you'd have known that by default that factory
produces non-validating parsers so the error must be somewhere else. Please
read before you start ask questions here and hope that others will do your work
for you. This entire thread has been useless until now because of that non-validating
default behaviour and you simply didn't know that because you haven't read the
API documentation.
kind regards,
Jos
If you had read the API documentation you'd have known that by default that factory
produces non-validating parsers so the error must be somewhere else. Please
read before you start ask questions here and hope that others will do your work
for you. This entire thread has been useless until now because of that non-validating
default behaviour and you simply didn't know that because you haven't read the
API documentation.
kind regards,
Jos
Yeah it's OK ......
Connection Refused Exception coming.
It tries to connect that DTD resource .....
How could I solve that?
Debasis Jana
Yeah it's OK ......
Connection Refused Exception coming.
It tries to connect that DTD resource .....
How could I solve that?
Debasis Jana
Try something like - documentBuilder.setEntityResolver(resolver);
where resolver is your own custom Resolver class implementing the org.xml.sax.Ent ityResolver interface. The implementation should read from your local file on disk and return the dtd (or schema). Am sure you can figure out how.
- talonx
Try something like - documentBuilder.setEntityResolver(resolver);
where resolver is your own custom Resolver class implementing the org.xml.sax.Ent ityResolver interface. The implementation should read from your local file on disk and return the dtd (or schema). Am sure you can figure out how.
- talonx
I need not to check whether it matches with DTD or not .....
I just want to bypass the DTD parsing .
I managed to do that ...by doing this .. -
jrxml.setEntityResolver(new EntityResolver() {
-
public InputSource resolveEntity(String publicId, String systemId) throws SAXException,IOException {
-
//return new InputSource("http://jasperreports.sourceforge.net/dtds/jasperreport.dtd");
-
return new InputSource(new ByteArrayInputStream(new byte[0]));
-
}
-
});
-
Thanks Jos and Thanks Others.
Debasis Jana
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Hari Prasad |
last post by:
Hi,
I am using XMLTool.java to convert an xml file into an xml document
and
I am parsing the xml file using Nodelist and Nodes.
NodeList ls = getElementsByTagName("xxx").
Its working fine when I am running my application in windows.
But when I am running the same application in unix, I am getting
exceptions while parsing. Its giving null value and I cannot proceed
further.
|
by: Dennis Roberts |
last post by:
I have a script to parse a dns querylog and generate some statistics.
For a 750MB file a perl script using the same methods (splits) can
parse the file in 3 minutes. My python script takes 25 minutes. It
is enough of a difference that unless I can figure out what I did
wrong or a better way of doing it I might not be able to use python
(since most of what I do is parsing various logs). The main reason to
try python is I had to look at...
|
by: Javier |
last post by:
Hello,
I'm very new in this forum and as I have the following problem,
the website is in http://new.vanara.com
----------------------------------------------------------------------------
--------------------------------------------
Here's how the site works:
You should press a button in the rollover area in order to load a source
file on an Iframe, this Iframe is actually hidden working as a Buffer. The
body of this loaded Iframe is...
|
by: Eric Lilja |
last post by:
Hello, I'm creating a small utility for an online game. It involves
parsing a text file of "tradesskill recipes" and inserting these
recipes in a gui tree widget (similar to gui file browsers if you know
what I mean).
Here's an example of a recipe as it appears in the text file:
* Cashew Pie (lvl 39, 5h 3 min, + max power)
- Candied Cashew (level 30)
-- Cashew
-- Refined Honey (level 30)
--- Raw Honey
|
by: Hugh |
last post by:
Hello,
I am having some problems understanding (most likely), parsing a text
file. I would like to parse a file like:
block1 {
stuff;
...
stuffN;
};
| |
by: Chris LaJoie |
last post by:
Hi,
I have an app that runs many simultaneous threads. I have noticed (took me
a while to figure out what it was doing though) that sometimes if there is a
problem, the thread will simply terminate on the line that caused a simple
exception, but does not throw any error or inform me in any way. I recently
found one of these problems in a function that does an int.Parse(string),
however, there are many more. I was apparently wrong in...
|
by: matvdl |
last post by:
I have a system that was originally developed in asp - the pages are saved in
SQL (there are over 10,000 pages) and saved to a temp directory in the server
when requested by a client.
I have updated this system and changed the pages that are saved to the
server as aspx - everything works fine and pages can be served - but
Its not impossible for a single client to request 100 plus pages in one
session - as each page is requested it is...
|
by: manstey |
last post by:
Hi,
I have a text file called a.txt:
# comments
I read it using this:
|
by: i80and |
last post by:
I'm working on a basic web spider, and I'm having problems with the
urlparser.
This is the effected function:
------------------------------
def FindLinks(Website):
WebsiteLen = len(Website)+1
CurrentLink = ''
i = 0
SpliceStart = 0
SpliceEnd = 0
|
by: charliefortune |
last post by:
I am fetching some product feeds with PHP like this
$merch = substr($key,1);
$feed = file_get_contents($_POST);
$fp = fopen("./feeds/feed".$merch.".txt","w+");
fwrite ($fp,$feed);
fclose ($fp);
and then parsing them with PHP's native parsing functions. This is
succesful for most of the feeds, but a couple of them claim to be
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
| |
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |