Advertisement
Guest User

Untitled

a guest
Oct 28th, 2011
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.61 KB | None | 0 0
  1. package parsepandaxsdfile;
  2.  
  3. import com.sun.xml.xsom.XSElementDecl;
  4. import com.sun.xml.xsom.XSSchema;
  5. import com.sun.xml.xsom.parser.XSOMParser;
  6. import com.sun.xml.xsom.XSSchemaSet;
  7. import com.sun.xml.xsom.XSType;
  8. import java.io.File;
  9. import java.io.FileInputStream;
  10. import java.io.FileNotFoundException;
  11. import java.io.InputStream;
  12. import java.io.InputStreamReader;
  13. import java.io.Reader;
  14. import java.io.UnsupportedEncodingException;
  15. import java.util.Iterator;
  16. import org.xml.sax.SAXException;
  17.  
  18. public class ParsePandaXSDFIle {
  19.  
  20. public static void main(String[] args) throws FileNotFoundException, UnsupportedEncodingException, SAXException {
  21. File file = new File("/home/rufatb/Desktop/untitled folder/5.1/test2.xsd");
  22.  
  23. if (file.exists()) {
  24.  
  25. XSOMParser parser = new XSOMParser();
  26. InputStream inputStream = new FileInputStream(file);
  27. Reader reader = new InputStreamReader(inputStream, "UTF-8");
  28.  
  29. parser.parse(reader);
  30. XSSchemaSet xs = parser.getResult();
  31.  
  32. XSSchema schema = xs.getSchema(1);
  33.  
  34. Iterator<XSElementDecl> itr = schema.iterateElementDecls();
  35.  
  36. while(itr.hasNext()){
  37.  
  38. XSElementDecl e = itr.next();
  39. XSType type = e.getType();
  40.  
  41. if(type.isComplexType()){
  42. // do something
  43. }
  44.  
  45.  
  46. }
  47.  
  48.  
  49.  
  50. }else{
  51. System.out.println("File not founded");
  52. }
  53. }
  54. }
  55.  
  56.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement