MINDMAKERS Forum
Welcome, Guest. Please login or register.
September 08, 2010, 02:27:52 PM

Login with username, password and session length
Search:     Advanced search
NB: Spam bots are becoming smarter every day - we had to turn off regular registration. To become member, please send email to Kris Thorisson ([kris'_lastname] att ru dott is).
337 Posts in 99 Topics by 99 Members
Latest Member: peterwit
* Home Help Search Login Register
+  MINDMAKERS Forum
|-+  Projects
| |-+  Psyclone (Moderator: cmlabs)
| | |-+  Java XML validator - a contribution
« previous next »
Pages: [1] Print
Author Topic: Java XML validator - a contribution  (Read 1514 times)
matija
Newbie
*
Posts: 11


View Profile Email
« on: October 30, 2007, 03:05:34 PM »

Hello,

Here is a small contribution towards XML validation in Java:
while there exists a XMLElement.java class with a parser in JavaOpenAIR distribution, I've found that messages
about XML errors are generally nicer (unfortunately this is not always true...)  when using the Sax Java parser (included in standard Java distributions).

So I' ve added my  SaxXmlValidator class to the com.cmlabs.thirdparty package.

Example of use:
   String xml = "<module name='JavaTest_Stream_reader' type='external' >"
      + "                 <triggers from='MyWB' >"
      + "                   <trigger type='TestStreams.DataSampleOutput' />"
      + "               <triggers>"
      + "      </module>";

   if (!SaxXmlValidator.checkXmlValidity(xml))
      System.out.print("checkXmlValidity FAILED on xml module registration string!");
   
the output:
   checkXmlValidity: SAXException: The element type "triggers" must be terminated by the matching end-tag "</triggers>".
   checkXmlValidity FAILED on xml module registration string!
   
The attached zip contains SaxXmlValidator .java and .class files.

yours,
Matija
Logged
thorlist
Jr. Member
**
Posts: 51


thorlist
View Profile WWW Email
« Reply #1 on: October 31, 2007, 10:05:53 AM »

Hi Majita,

This is a really nice addition - thank you so much for this. I am sure that many OpenAIR users will be very happy to have this functionality.

This will be added to the next release of Java OpenAIR.

Best,
Thor
Logged
Pages: [1] Print 
« previous next »
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.4 | SMF © 2006-2007, Simple Machines LLC Valid XHTML 1.0! Valid CSS!