Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package parsepandaxsdfile;
- import com.sun.xml.xsom.XSElementDecl;
- import com.sun.xml.xsom.XSSchema;
- import com.sun.xml.xsom.parser.XSOMParser;
- import com.sun.xml.xsom.XSSchemaSet;
- import com.sun.xml.xsom.XSType;
- import java.io.File;
- import java.io.FileInputStream;
- import java.io.FileNotFoundException;
- import java.io.InputStream;
- import java.io.InputStreamReader;
- import java.io.Reader;
- import java.io.UnsupportedEncodingException;
- import java.util.Iterator;
- import org.xml.sax.SAXException;
- public class ParsePandaXSDFIle {
- public static void main(String[] args) throws FileNotFoundException, UnsupportedEncodingException, SAXException {
- File file = new File("/home/rufatb/Desktop/untitled folder/5.1/test2.xsd");
- if (file.exists()) {
- XSOMParser parser = new XSOMParser();
- InputStream inputStream = new FileInputStream(file);
- Reader reader = new InputStreamReader(inputStream, "UTF-8");
- parser.parse(reader);
- XSSchemaSet xs = parser.getResult();
- XSSchema schema = xs.getSchema(1);
- Iterator<XSElementDecl> itr = schema.iterateElementDecls();
- while(itr.hasNext()){
- XSElementDecl e = itr.next();
- XSType type = e.getType();
- if(type.isComplexType()){
- // do something
- }
- }
- }else{
- System.out.println("File not founded");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement