From: Kurt R. <kr...@us...> - 2005-04-22 14:46:22
|
Update of /cvsroot/xframe/xsddoc/src/net/sf/xframe/xsddoc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14473/src/net/sf/xframe/xsddoc Modified Files: Task.java Main.java Processor.java Log Message: support for new paramters -launch and -cf Index: Task.java =================================================================== RCS file: /cvsroot/xframe/xsddoc/src/net/sf/xframe/xsddoc/Task.java,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** Task.java 26 Feb 2005 14:03:38 -0000 1.21 --- Task.java 22 Apr 2005 14:46:08 -0000 1.22 *************** *** 292,304 **** /** * Adds a schema defined by a file name to a mediator schema. * * @param mediatorSchema the meditator schema * @param base base file to resolve relative paths ! * @param schemaLocation the schema to add */ private void addSchema(final Document mediatorSchema, final String base, final String schemaLocation) { - if (verbose) { - System.out.println("found schema " + schemaLocation); - } String namespace = null; namespace = getNamespace(base, schemaLocation); --- 292,303 ---- /** * Adds a schema defined by a file name to a mediator schema. + * If the document at the given schema location is not a schema file, + * the document is not added. * * @param mediatorSchema the meditator schema * @param base base file to resolve relative paths ! * @param schemaLocation location of the schema to add */ private void addSchema(final Document mediatorSchema, final String base, final String schemaLocation) { String namespace = null; namespace = getNamespace(base, schemaLocation); *************** *** 309,312 **** --- 308,314 ---- return; } + if (verbose) { + System.out.println("found schema " + schemaLocation); + } final Element importNode = mediatorSchema.createElementNS(SCHEMA_NS, "import"); final String projectDir = getProject().getBaseDir().getAbsolutePath() + File.separator; *************** *** 317,320 **** --- 319,323 ---- final String schemaLoc; //Does the base have additional information? + // TODO check the following against mail from Gianluca Chiozzi if (base.length() > projectDir.length() && base.startsWith(projectDir)) { String relativePath = base.substring(projectDir.length()); *************** *** 330,337 **** /** * Extracts and returns the target namespace from a schema file. * * @param base base file name to resolve relative paths * @param filename file name of schema file ! * @return target namespace of schema */ private String getNamespace(final String base, final String filename) { --- 333,343 ---- /** * Extracts and returns the target namespace from a schema file. + * The target namespace can be the empty string if the schema has no + * target namespace. If the document is not a XML Schema, the returned value + * is <tt>null</tt>. * * @param base base file name to resolve relative paths * @param filename file name of schema file ! * @return target namespace of schema or <tt>null</tt> if the document is not a schema */ private String getNamespace(final String base, final String filename) { *************** *** 339,342 **** --- 345,351 ---- final Document schema = getDocumentBuilder().parse(new File(base, filename)); final Element root = schema.getDocumentElement(); + if (!root.getLocalName().equals("schema") || !root.getNamespaceURI().equals(Task.SCHEMA_NS)) { + return null; + } return root.getAttribute("targetNamespace"); } catch (Exception e) { *************** *** 595,598 **** --- 604,625 ---- /** + * Setter method for createFolder attribute. + * + * @param createFolder if out folder should be created + */ + protected void setCreateFolder(final boolean createFolder) { + processor.setCreateFolder(createFolder); + } + + /** + * Setter method for lauch attribute. + * + * @param launch if documentation should be launched in browser + */ + protected void setLauch(final boolean launch) { + processor.setLaunch(launch); + } + + /** * An HTML fragment in a nested element of the xsddoc task. * Index: Processor.java =================================================================== RCS file: /cvsroot/xframe/xsddoc/src/net/sf/xframe/xsddoc/Processor.java,v retrieving revision 1.37 retrieving revision 1.38 diff -C2 -d -r1.37 -r1.38 *** Processor.java 3 Mar 2005 17:10:13 -0000 1.37 --- Processor.java 22 Apr 2005 14:46:08 -0000 1.38 *************** *** 49,52 **** --- 49,53 ---- import net.sf.xframe.ex.ExceptionUtil; + import net.sf.xframe.xsddoc.util.BrowserLauncher; import net.sf.xframe.xsddoc.util.DomUtil; import net.sf.xframe.xsddoc.util.FileUtil; *************** *** 197,200 **** --- 198,207 ---- private boolean debug = false; + /** if generated documentation should be launched after creation. */ + private boolean launch = false; + + /** if output folder should be created. */ + private boolean createFolder = false; + /** if xml mode or not. */ private boolean xml = false; *************** *** 348,351 **** --- 355,394 ---- /** + * Getter method for createFolder property. + * + * @return if output folder should be created + */ + protected boolean isCreateFolder() { + return createFolder; + } + + /** + * Setter method for createFolder property. + * + * @param theCreateFolder if output folder should be created + */ + protected void setCreateFolder(final boolean theCreateFolder) { + this.createFolder = theCreateFolder; + } + + /** + * Getter method for launch property. + * + * @return if generated documentation should be launched after creation + */ + protected boolean isLaunch() { + return launch; + } + + /** + * Setter method for launch property. + * + * @param theLaunch if generated documentation should be launched after creation + */ + protected void setLaunch(final boolean theLaunch) { + this.launch = theLaunch; + } + + /** * Setter method for xml property. * *************** *** 460,463 **** --- 503,514 ---- } final File outFile = new File(this.out); + + if (!outFile.exists()) { + if (createFolder) { + outFile.mkdirs(); + } else { + throw new ProcessorException("output folder doesn't exist: " + outFile); + } + } if (!outFile.exists()) { throw new ProcessorException("output folder doesn't exist: " + outFile); *************** *** 473,476 **** --- 524,530 ---- } process(); + if (launch) { + BrowserLauncher.openURL(out + FILE_SEP + "index" + getExtension()); + } } catch (Exception e) { throw new ProcessorException(e.getLocalizedMessage(), e); Index: Main.java =================================================================== RCS file: /cvsroot/xframe/xsddoc/src/net/sf/xframe/xsddoc/Main.java,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** Main.java 26 Feb 2005 14:03:38 -0000 1.24 --- Main.java 22 Apr 2005 14:46:08 -0000 1.25 *************** *** 44,47 **** --- 44,49 ---- * -css <css-file> provide external CSS file * -version Only output version of xsddoc + * -launch Launch documentation after creation + * -cf Create output folder if not exists * -d -debug Output debug messages * -? -help Print this help message *************** *** 108,111 **** --- 110,117 ---- } else if ("x".equals(option) || "xml".equals(option)) { processor.setXml(true); + } else if ("cf".equals(option)) { + processor.setCreateFolder(true); + } else if ("launch".equals(option)) { + processor.setLaunch(true); } else if ("version".equals(option)) { System.out.println("xframe - xsddoc version " + VERSION); *************** *** 161,169 **** System.out.println(" -g -hideGroups hide groups in overview pages"); System.out.println(" -a -hideAttributes hide attributes in overview pages"); System.out.println(" -xml output as XML instead of HTML"); System.out.println(" -version Only output version of xsddoc"); System.out.println(" -d -debug Output debug messages"); System.out.println(" -? -help Print this help message"); } - } --- 167,177 ---- System.out.println(" -g -hideGroups hide groups in overview pages"); System.out.println(" -a -hideAttributes hide attributes in overview pages"); + System.out.println(" -css <css-file> provide external CSS file"); System.out.println(" -xml output as XML instead of HTML"); + System.out.println(" -launch Launch documentation after creation"); + System.out.println(" -cf Create output folder if not exists"); System.out.println(" -version Only output version of xsddoc"); System.out.println(" -d -debug Output debug messages"); System.out.println(" -? -help Print this help message"); } } |