IMPORTANT:
this is not a Support Forum! Experienced users might answer from time to time questions posted here. If you need a professional and reliable answer, or if you want to report a bug, please contact Altova Support instead.

Java w/ XMLSpy Options · View
Austind5
Posted: Friday, June 9, 2017 11:20:33 AM
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.
island
Posted: Tuesday, June 13, 2017 12:52:06 PM
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 )
        {    

        }
        
    }
}
Users browsing this topic
guest

Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Use of the Altova User Forum(s) is governed by the Altova Terms of Use.