• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

enhancing performance for validating xml against a xsd using xerces if xsd is large

 
Ranch Hand
Posts: 93
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,

i am trying to validate a xml against a xsd using xerces but the problem is

that the xsd is quite huge as a result the code is taking very long to

validate the xml

if some one can help to enhance the performance???

thanks in advance
 
Ranch Hand
Posts: 183
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Ashok,

If it is the case that you are validating mutiple XML documents against the same schema we can save some time using the Schema compilation features introduced in JAXP 1.3 built into Java 1.5 by default.

For more details read this article http://java.sun.com/developer/technicalArticles/xml/jaxp1-3/#Schema_Validation_Framework

The XML Forums would be more appropriate for this question

-Rajagopal
[ December 27, 2005: Message edited by: Rajagopal Manohar ]
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yup, let's move it to the XML forum.
 
Ashok Kumar
Ranch Hand
Posts: 93
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi
rajagopal just one doubt if you are using java 1.4 then how to move on and moreover I am not validating multiple xml but a single xml using xerces I am attaching the code also actually the xsd is pretty large like 1.2 mb I believe this is the reason for it. If you have any suggestion it will be of great help

thanx

code:

import org.apache.xerces.parsers.SAXParser;
import java.io.File;
import org.w3c.dom.Document;
import java.util.*;

public class ValidateWithSchema {

public static void main (String args[])
{
File docFile = new File("ReadyForms_111505_Ca_9997.xml");
try

{
//Calendar c = new Calendar();
//long l =c.time;
Calendar cal = Calendar.getInstance(TimeZone.getDefault());

System.out.println(cal.getTime());
SAXParser parser = new SAXParser();
parser.setFeature("http://xml.org/sax/features/validation", true);
parser.setProperty(
"http://apache.org/xml/properties/schema/external-noNamespaceSchemaLocation",
"D:/xslt/xml_xslt/transform/ReadyForms_111505.xsd");
ErrorChecker errors = new ErrorChecker();
parser.setErrorHandler(errors);
parser.parse("D:/xslt/xml_xslt/ca form mapping/ReadyForms_111505_Ca_9914.xml");
//long l1 = c.time;
Calendar cal1 = Calendar.getInstance(TimeZone.getDefault());
System.out.println(cal1.getTime());
}
catch (Exception e)
{
System.out.print("Problem parsing the file.");
}
}

}
 
Marshal
Posts: 28425
102
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A schema that is 1.2 megabytes of XML? I think you should consider simplifying that schema. Radically simplifying it.
 
Ashok Kumar
Ranch Hand
Posts: 93
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi paul,

Actually its not possible for us to reduce the schema from our part since that is not developed from our company do u have any other suggestion in order to improve the efficiency.
 
Rajagopal Manohar
Ranch Hand
Posts: 183
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Ashok Kumar:
Hi paul,

Actually its not possible for us to reduce the schema from our part since that is not developed from our company do u have any other suggestion in order to improve the efficiency.



I understand, even we had to grapple with this issue once where the schema size was even larger (4MB).

But even then it did not take more than 5 seconds (approx) for the first time we validated and all subsequent validations took very less time.

I guess this is so because the XSD is being parsed during the first run.

PS: Also I've heard that there is a JAXP 1.3 kit available for jdk 1.4

-Rajagopal
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic