Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » PHP Development Tools (PDT) » Custom Validation Issues
Custom Validation Issues [message #891817] Tue, 26 June 2012 06:51 Go to next message
rohit chawla is currently offline rohit chawla
Messages: 19
Registered: June 2012
Junior Member
Hi guys,

I want to validate a document, with an custom validator. Want to validate it with a xsd, but only aftter certain preprocessing of main document.
Custom validator is required instead of normal xml validator, because the schema location is not defined in the main file & also I want to do some preprocessing to the file, before applying xsd validation.

My plugin.xml is as follows:

<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>

<extension
point="org.eclipse.core.runtime.contentTypes">
<content-type
id="com.xyz.ide.core.contentType.dummy"
base-type="org.eclipse.core.runtime.xml"
file-extensions="blabla"
/>
</extension>
<extension
point="org.eclipse.wst.sse.ui.sourcevalidation">
<validator
scope="total"
class="mc.CustomValidator"
id="com.xyz.ide.ui.editors.page.validator">
<contentTypeIdentifier
id="com.xyz.ide.core.contentType.dummy">
<partitionType
id="org.eclipse.wst.xml.XML_DEFAULT">
</partitionType>
</contentTypeIdentifier>
</validator>
</extension>

</plugin>

CustomValidator.java

public class CustomValidator implements ISourceValidator, IValidator {
XMLValidator validator = new XMLValidator();
IDocument document;

public void validate(IValidationContext helper, IReporter reporter) {
String fileContent = this.document.get();
final InputStream is = new ByteArrayInputStream(fileContent.toLowerCase().getBytes());
XMLValidationReport report = validator.validate("/home/rchawla/xmlWorkspace/abc.xsd", is);
ValidationMessage[] messages = report.getValidationMessages();
for(ValidationMessage message:messages){
System.out.println(message.getMessage());
}
}

The problem is that the execution point does come to the above validate method, but
How can I associate xsd to the xmlvalidator object and validate it. Write now, ValidationMessage[] messages = report.getValidationMessages(); is giving zero messages, even though the there are errors in the main file.
Re: Custom Validation Issues [message #891850 is a reply to message #891817] Tue, 26 June 2012 09:38 Go to previous message
Toshihiro Izumi is currently offline Toshihiro Izumi
Messages: 351
Registered: July 2009
Location: Japan
Senior Member
You're in the wrong forum. Your problem is covered at WTP forum.
FYI,
http://www.eclipse.org/forums/index.php/mv/msg/72654/227336/#msg_227336
Previous Topic:An internal error occurred during: "Processing Dirty Regions". Java heap space
Next Topic:Fatal Error Launching Zend Debugger Eclipse 3.0.2
Goto Forum:
  


Current Time: Tue Oct 21 12:15:56 GMT 2014

Powered by FUDForum. Page generated in 0.03172 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software