/* * SchemaEditor.java * * Created on 13 May 2003, 12:08 */ package com.jrockey.xsdedit; import java.io.File; import java.io.FileReader; import java.lang.StringBuffer; import java.lang.reflect.*; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import org.apache.xerces.impl.xs.psvi.*; import org.apache.xerces.parsers.XMLGrammarPreparser; import org.apache.xerces.xni.grammars.Grammar; import org.apache.xerces.xni.grammars.XSGrammar; import org.apache.xerces.xni.parser.XMLInputSource; import org.w3c.dom.Document; /** * * @author zz9j08 */ public class SchemaEditor { public static final String schemaNamespace = "http://www.w3.org/2001/XMLSchema"; /** Creates a new instance of SchemaEditor */ public SchemaEditor() { } /** * @param args the command line arguments */ public static void main(String[] args) { try { String filePath = "d:/usr/home/zz9j08/xml/docreq.xsd"; //String filePath = "d:/usr/home/zz9j08/xml/PrismRealTime_v1.1.xsd"; //String filePath = "/home/julian/temp/articles.xsd"; DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); DocumentBuilder docbuild = dbf.newDocumentBuilder(); Document d = docbuild.parse(filePath); System.out.println("parsed OK"); XMLGrammarPreparser gpp = new XMLGrammarPreparser(); gpp.registerPreparser(schemaNamespace, null); String url = new File(filePath).toURL().toExternalForm(); XMLInputSource is = new XMLInputSource(url, url, null, new FileReader(filePath), null); Grammar g = gpp.preparseGrammar(schemaNamespace, is); System.out.println("Parsed grammar OK"); XSGrammar xsg = (XSGrammar)g; XSModel model = xsg.toXSModel(); System.out.println("Converted to XS Model OK"); System.out.println(""); System.out.println("TYPES:"); Class cl = XSNamedMap.class; Method[] meths = cl.getDeclaredMethods(); for(int c=0; c