Rank: Newbie
Joined: 6/9/2017 Posts: 3 Location: Virginia
|
I am sorry if this question has been asked before, I am new to the site.
I am working with XML Spy and have a very simple XML document (1 root element, 3 elements and 6 children) and a simple XSD document. I put two errors in the XML document and need to use Java to find the errors, also worth noting that I can only import the packages that come with XML Spy and cannot download a parser like MSXML.
As of right now my code validates the XML document against the XSD schema, but will only go to the first error and outputs the error messages. Is there a way to validate and output all errors in the document?
I am new to XML Spy and understand this may be a very simple fix..
Thank you.
|
Rank: Newbie
Joined: 10/28/2002 Posts: 1,283 Location: AT
|
Hi,
try using the isValidEx method: The second argument lets you define the error limit
Code: import com.altova.automation.XMLSpy.*; import com.altova.automation.libs.*;
public class validatexml {
public static void main(String[] args) {
JVariant validationErrorText = new JVariant.JStringVariant(""); validationErrorText.setByRefFlag(); boolean valid;
try{ Application a = new Application(); a.showApplication(true); //valid = a.getDocuments().openFile("c:\\test1.xml", false).isValid(validationErrorText, validationErrorCount, validationErrorXMLData); valid = a.getDocuments().openFile("c:\\test1.xml", false).isValidEx(Enums.SPYValidateXSDVersion.spyValidateXSDVersion_1_0 , 999, Enums.SPYValidateErrorFormat.SPYValidateErrorFormat_Text, validationErrorText); System.out.println(valid); System.out.println(validationErrorText.getStringValue()); } catch(Exception e ) { } } }
|