LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 03-20-2009, 03:43 PM   #1
manolakis
Member
 
Registered: Nov 2006
Distribution: xubuntu
Posts: 444

Rep: Reputation: 31
XML Schemas and Java XML Parsers


Hi there,

I have seen a number of tutorials for parsing an XML file with Java XML Parsers but I have failed to find any tutorial for validating an XML file according to its schema with a Java Parser.
Can anyone list any tutorial or give some sample code.

Many thanks.
 
Old 03-20-2009, 09:51 PM   #2
paulsm4
LQ Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
The standard parsers that come with the JDK should all be validating parsers these days. So all you have to do is turn on validation when you create the object:
Code:
   // EXAMPLE:
   SAXParserFactory factory = SAXParserFactory.newInstance();
   factory.setValidating(true);
Here's a more elaborate example (you can easily find better, newer and more comprehensive examples, I'm sure):

http://java.sun.com/j2ee/1.4/docs/tu.../JAXPDOM8.html

'Hope that helps .. PSM
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
checking for XML::Parser... configure: error: XML::Parser perl module is required for kornerr Linux - General 11 11-16-2008 08:24 AM
LXer: Thinking XML: Firefox 3.0 and XML LXer Syndicated Linux News 0 07-30-2008 07:50 PM
no xml, convert tvtime stationlist to xml for mythtv/freevo... frenchn00b Linux - General 8 11-04-2007 12:35 AM
LXer: StAX’ing up XML: Streaming API for XML LXer Syndicated Linux News 0 11-30-2006 08:54 AM
configure: error: could not find DocBook XML DTD V4.1.2 in XML catalog Fadoksi Linux - Software 1 07-16-2006 07:41 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:21 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration