It's not a secret anymore!*
The moose likes Other JSE/JEE APIs and the fly likes jdom xml schema validation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Other JSE/JEE APIs
Bookmark "jdom xml schema validation" Watch "jdom xml schema validation" New topic
Author

jdom xml schema validation

Christina Cardino
Greenhorn

Joined: Jun 03, 2008
Posts: 3
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

Joined: Jul 11, 2001
Posts: 14112
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 soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 40052
    
  28
. . . 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

Joined: Oct 27, 2005
Posts: 19785
    
  20

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 ]

SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Christina Cardino
Greenhorn

Joined: Jun 03, 2008
Posts: 3
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

Joined: Jul 11, 2001
Posts: 14112
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

Joined: Oct 27, 2005
Posts: 19785
    
  20

I'm going to move this to Other APIs as it's a JDOM specific problem.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: jdom xml schema validation