File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

jdom xml schema validation

 
Christina Cardino
Greenhorn
Posts: 3
  • 0
  • Mark post as helpful
  • send pies
  • 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 ]
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • 0
  • Mark post as helpful
  • send pies
  • 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.
 
Campbell Ritchie
Sheriff
Pie
Posts: 47229
52
  • 0
  • Mark post as helpful
  • send pies
  • 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.
 
Rob Spoor
Sheriff
Pie
Posts: 20369
44
Chrome Eclipse IDE Java Windows
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • 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
Sheriff
Posts: 14112
  • 0
  • Mark post as helpful
  • send pies
  • 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
Pie
Posts: 20369
44
Chrome Eclipse IDE Java Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm going to move this to Other APIs as it's a JDOM specific problem.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic