• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

jdom xml schema validation

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I have the following code to validate an xml document with an xml schema(please refer below). It's giving an error shown below.

Please help!

Thanks,

Tina

Error
--------------------------------------------
57 cannot find symbol symbol : method setFeature(java.lang.String,boolean)
location: class org.jdom.input.SAXBuilder
builder.setFeature("http://xml.org/sax/features/validation", true);

58: cannot find symbol symbol : method setFeature(java.lang.String,boolean)
location: class org.jdom.input.SAXBuilder
builder.setFeature("http://apache.org/xml/features/validation/schema", true);

59: cannot find symbol symbol : method setFeature(java.lang.String,boolean)
location: class org.jdom.input.SAXBuilder
builder.setFeature("http://apache.org/xml/features/validation/schema-full-checking", true);

60: cannot find symbol symbol : method setProperty(java.lang.String,java.lang.String)
location: class org.jdom.input.SAXBuilder
builder.setProperty("http://apache.org/xml/properties/schema/external-noNamespaceSchemaLocation",xsdFile);


java file
--------------------
import org.jdom.* ;
import org.jdom.input.*;
import org.jdom.output.* ;
import org.jdom.xpath.*;
import java.util.regex.*;

import java.util.*;
import java.io.*;

public wc
{
SAXBuilder builder = new SAXBuilder();
builder.setFeature("http://xml.org/sax/features/validation", true);
builder.setFeature("http://apache.org/xml/features/validation/schema", true);
builder.setFeature("http://apache.org/xml/features/validation/schema-full-checking", true);
builder.setProperty("http://apache.org/xml/properties/schema/external-noNamespaceSchemaLocation",xsdFile);

Document doc = builder.build(new File("C:\\myJavaStuff\\ISE\\programming\\ise_3_1.xml"));

}

---------------------------------------------------------
xml file
-----------
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ns2:Schedules xmlns:ns1="http://mie.edu/niem/structures/2.0" xmlns:ns2="http://iljiseda.dlsa.com" xmlns:ns3="http://mie.edu/niem/niem-core/2.0" xmlns:ns4="http://mie.edu/niem/appinfo/2.0">
<ns2:Schedule ReasonCode="M">
<ns2 rganizationAgencyName>AB</ns2 rganizationAgencyName>
<ns3 rganizationBranchName>Newport</ns3 rganizationBranchName>
<ns3:IdentificationID>bfletcher</ns3:IdentificationID>
<ns3 :p ersonGivenName>Ben</ns3 :p ersonGivenName>
<ns3 :p ersonMiddleName>Anton</ns3 :p ersonMiddleName>
<ns3 :p ersonSurName>Fletcher</ns3 :p ersonSurName>
<ns2:StartDate>2008-05-26-07:00</ns2:StartDate>
<ns2:EndDate>2008-06-01-07:00</ns2:EndDate>
</ns2:Schedule>
<ns2:Schedule ReasonCode="T">
<ns2 rganizationAgencyName>AB</ns2 rganizationAgencyName>
<ns3 rganizationBranchName>Newport Beach</ns3 rganizationBranchName>
<ns3:IdentificationID>opearson</ns3:IdentificationID>
<ns3 :p ersonGivenName>Oscar</ns3 :p ersonGivenName>
<ns3 :p ersonMiddleName></ns3 :p ersonMiddleName>
<ns3 :p ersonSurName>Pearson</ns3 :p ersonSurName>
<ns2:StartDate>2008-06-02-07:00</ns2:StartDate>
<ns2:EndDate>2008-06-08-07:00</ns2:EndDate>
</ns2:Schedule>
</ns2:Schedules>
[ June 04, 2008: Message edited by: Christina Cardino ]
 
author
Posts: 14112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What the compiler is telling you is that the SaxBuilder class of JDom (at least of the version you are using) doesn't have a setFeature method, nor a setProperty method, with the parameter types you provided.
 
Marshal
Posts: 79177
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
. . . and welcome to JavaRanch

Please go back to edit your post with the pencil-and-paper icon, then click "disable smilies" on the bottom left, which will get rid of the effect.
 
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Ilja Preuss:
What the compiler is telling you is that the SaxBuilder class of JDom (at least of the version you are using) doesn't have a setFeature method, nor a setProperty method, with the parameter types you provided.


The API says it does. So the question then is: are you using the latest version? Perhaps this method has been added after you downloaded JDOM.

I recall having some problems when JDOM went from 0.9 to 1.0, and they changed some of the core API. I was quite annoyed they did that - they clearly didn't think about anybody using their library.
[ June 04, 2008: Message edited by: Rob Prime ]
 
Christina Cardino
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm using Eclipse as an editor with ant as the compiler. What puzzles me is that I can see the function in the IntelliSense in the Eclipse editor, but when I compile, it gives that error.

I already checked the ant build file and the Java Build Path jar libraries, both are pointing to the same jdom.jar.

Thanks for your help.
 
Ilja Preuss
author
Posts: 14112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Rob Prime:

I recall having some problems when JDOM went from 0.9 to 1.0, and they changed some of the core API. I was quite annoyed they did that - they clearly didn't think about anybody using their library.



Well, I actually think they did - that's why they called it 0.9. If I remember correctly, they very openly warned about the possibility of major API changes until the 1.0 release. So if you used it anyway, you should have been aware of the risk.
 
Rob Spoor
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm going to move this to Other APIs as it's a JDOM specific problem.
reply
    Bookmark Topic Watch Topic
  • New Topic