# HG changeset patch # User smith@nwoca.org # Date 1307484367 14400 # Node ID 09f9f3d5c507767bd9b3ad41dff215c9832d23f7 # Parent 82fc5e17cc59d9c777f404b045861bb54861a099 CM-127: Move wsdlsetup and wsd2html.xsl from Tools diff -r 82fc5e17cc59 -r 09f9f3d5c507 nbproject/build-impl.xml --- a/nbproject/build-impl.xml Sat Apr 16 16:22:27 2011 -0400 +++ b/nbproject/build-impl.xml Tue Jun 07 18:06:07 2011 -0400 @@ -57,7 +57,14 @@ - + + + + + + + + @@ -72,8 +79,14 @@ + + + + + + @@ -86,40 +99,41 @@ - - - - - - - - - - - + + + + + + + + + + + + - - - - - + + + + + - - - - - + + + + + @@ -175,8 +189,17 @@ - + + + + + + + + + + @@ -304,7 +327,9 @@ - + + + @@ -314,7 +339,8 @@ - + + @@ -330,11 +356,56 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set JVM to use for profiling in profiler.info.jvm + Must set profiler agent JVM arguments in profiler.info.jvmargs.agent + @@ -429,6 +500,7 @@ + @@ -444,7 +516,7 @@ - + @@ -573,10 +645,10 @@ - + - + @@ -585,44 +657,53 @@ - To run this application from the command line without Ant, try: + To run this application from the command line without Ant, try: - java -cp "${run.classpath.with.dist.jar}" ${main.class} + java -cp "${run.classpath.with.dist.jar}" ${main.class} + + + + - + + + + + + + + + + - - - - - - - To run this application from the command line without Ant, try: - - java -jar "${dist.jar.resolved}" + + + - - - - - - - To run this application from the command line without Ant, try: + + + To run this application from the command line without Ant, try: - java -jar "${dist.jar.resolved}" + java -jar "${dist.jar.resolved}" + + + + + + - + + + + + + + + + + + Must select one file in the IDE or set profile.class + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + Must select some files in the IDE or set javac.includes diff -r 82fc5e17cc59 -r 09f9f3d5c507 nbproject/genfiles.properties --- a/nbproject/genfiles.properties Sat Apr 16 16:22:27 2011 -0400 +++ b/nbproject/genfiles.properties Tue Jun 07 18:06:07 2011 -0400 @@ -4,8 +4,8 @@ # This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. # Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. nbproject/build-impl.xml.data.CRC32=f0bc348c -nbproject/build-impl.xml.script.CRC32=68cd5525 -nbproject/build-impl.xml.stylesheet.CRC32=229523de@1.38.3.45 +nbproject/build-impl.xml.script.CRC32=0c44830b +nbproject/build-impl.xml.stylesheet.CRC32=0c01fd8e@1.43.1.45 nbproject/groovy-build.xml.data.CRC32=f0bc348c nbproject/groovy-build.xml.script.CRC32=542f299d nbproject/groovy-build.xml.stylesheet.CRC32=451a613c@1.12.1 diff -r 82fc5e17cc59 -r 09f9f3d5c507 src/org/ssdt_ohio/tools/ant/WsdlSetup.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/org/ssdt_ohio/tools/ant/WsdlSetup.java Tue Jun 07 18:06:07 2011 -0400 @@ -0,0 +1,270 @@ +/* Copyright 2003 Ohio Department of Education, Office of Information Technology, + * 25 South Front St, Columbus, Ohio 43215, U.S.A., All Rights Reserved. + */ +package org.ssdt_ohio.tools.ant; + +import java.io.File; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.transform.Transformer; +import javax.xml.transform.TransformerFactory; +import javax.xml.transform.dom.DOMSource; +import javax.xml.transform.stream.StreamResult; + +import org.apache.tools.ant.BuildException; +import org.apache.tools.ant.Task; + +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; + +import java.util.regex.Pattern; + +/** Simple ant task for maniuplating WSDL settings. + * + * + * @author smith + * @since 2007-8-1 + */ +public class WsdlSetup + extends Task { + + private static final String SCHEMA_NS = "http://www.w3.org/2001/XMLSchema"; + private static final String OECNRPC_NS = "http://xml.ssdt.nwoca.org/OECN-RPC/10"; + private final List locations = new ArrayList(); /* Store locations */ + + private String file; + private String destfile; + private String typesFile; + private String typesPattern = ".*Fault$"; + private boolean elementFormDefaultQualified = true; + + public void execute() { + if (file == null) { + throw new BuildException("must specify 'file' as input file"); + } + + if (destfile == null) { + throw new BuildException("must specify 'destfile' as output file"); + } + + try { + DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); + dbf.setNamespaceAware(true); + + Document wsdl = dbf.newDocumentBuilder().parse(new File(getFile())); + NodeList imports = wsdl.getElementsByTagNameNS(SCHEMA_NS, "import"); + + for (int i = 0; i < imports.getLength(); i++) { + replaceLocations((Element) imports.item(i)); + } + + TransformerFactory tFactory = TransformerFactory.newInstance(); + Transformer transformer = tFactory.newTransformer(); + DOMSource source = new DOMSource(wsdl); + StreamResult result = new StreamResult(new File(getDestfile())); + transformer.transform(source, result); + + if (typesFile != null) { + generateTypesSchema(wsdl); + } + } catch (javax.xml.parsers.ParserConfigurationException e) { + throw new BuildException(e); + } catch (org.xml.sax.SAXException e) { + throw new BuildException(e); + } catch (java.io.IOException e) { + throw new BuildException(e); + } catch (javax.xml.transform.TransformerException e) { + throw new BuildException(e); + } + } + + private void replaceLocations(Element imp) { + String ns = imp.getAttribute("namespace"); + + for (Iterator it = locations.iterator(); it.hasNext();) { + SchemaLocation loc = (SchemaLocation) it.next(); + + if (ns.equals(loc.getNamespace())) { + imp.setAttribute("schemaLocation", loc.getLocation()); + } + } + } + + private void generateTypesSchema(Document wsdl) + throws BuildException { + try { + DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); + dbf.setNamespaceAware(true); + + Document schema = dbf.newDocumentBuilder().newDocument(); + Element root = (Element) wsdl.getElementsByTagNameNS(SCHEMA_NS, + "schema").item(0); + String targetNamespace = root.getAttribute("targetNamespace"); + + schema.appendChild(schema.importNode(root, true)); + root = schema.getDocumentElement(); + root.setAttribute("xmlns:xsd", SCHEMA_NS); + if (isElementFormDefaultQualified()) { + root.setAttribute("elementFormDefault", "qualified"); + } + root.setAttribute("xmlns", targetNamespace); + root.setAttribute("xmlns:oecnrpc", OECNRPC_NS); + + for (Iterator it = locations.iterator(); it.hasNext();) { + SchemaLocation loc = (SchemaLocation) it.next(); + + if (loc.getPrefix() != null) { + root.setAttribute("xmlns:" + loc.getPrefix(), loc.getNamespace()); + } + } + + // Remove everything except the included types. + boolean done = false; + + Pattern typesPat = Pattern.compile(getTypesPattern()); + + while (!done) { + done = true; + + NodeList children = root.getChildNodes(); + + for (int i = 0; i < children.getLength(); i++) { + if (children.item(i).getNodeType() == Node.ELEMENT_NODE) { + Element e = (Element) children.item(i); + + if (!e.getLocalName().equals("import") && !typesPat.matcher(e. + getAttribute("name")).matches()) { + root.removeChild(e); + done = false; + } + } + } + } + TransformerFactory tFactory = TransformerFactory.newInstance(); + Transformer transformer = tFactory.newTransformer(); + + DOMSource source = new DOMSource(schema); + StreamResult result = new StreamResult(new File(getTypesFile())); + transformer.transform(source, result); + } catch (Exception e) { + throw new BuildException(e); + } + } + + public SchemaLocation createSchemaLocation() { + SchemaLocation loc = new SchemaLocation(); + locations.add(loc); + + return loc; + } + + /** + * Getter for property file. + * @return Value of property file. + */ + public java.lang.String getFile() { + return file; + } + + /** + * Setter for property file. + * @param file New value of property file. + */ + public void setFile(java.lang.String file) { + this.file = file; + } + + /** + * Getter for property destfile. + * @return Value of property destfile. + */ + public java.lang.String getDestfile() { + return destfile; + } + + /** + * Setter for property destfile. + * @param destfile New value of property destfile. + */ + public void setDestfile(java.lang.String destfile) { + this.destfile = destfile; + } + + /** + * Getter for property typesFile. + * @return Value of property typesFile. + */ + public java.lang.String getTypesFile() { + return typesFile; + } + + /** + * Setter for property typesFile. + * @param typesFile New value of property typesFile. + */ + public void setTypesFile(java.lang.String typesFile) { + this.typesFile = typesFile; + } + + /** + * @return the elementFormDefaultQualified + */ + public boolean isElementFormDefaultQualified() { + return elementFormDefaultQualified; + } + + /** + * @param elementFormDefaultQualified the elementFormDefaultQualified to set + */ + public void setElementFormDefaultQualified(boolean elementFormDefaultQualified) { + this.elementFormDefaultQualified = elementFormDefaultQualified; + } + + /** A nested 'schemaLocation' object. */ + public class SchemaLocation { + + private String namespace; + private String location; + private String prefix; + + public SchemaLocation() { + } + + public java.lang.String getNamespace() { + return namespace; + } + + public void setNamespace(java.lang.String namespace) { + this.namespace = namespace; + } + + public java.lang.String getLocation() { + return location; + } + + public void setLocation(java.lang.String location) { + this.location = location; + } + + public String getPrefix() { + return prefix; + } + + public void setPrefix(String prefix) { + this.prefix = prefix; + } + } + + public String getTypesPattern() { + return typesPattern; + } + + public void setTypesPattern(String typesPattern) { + this.typesPattern = typesPattern; + } +} diff -r 82fc5e17cc59 -r 09f9f3d5c507 src/org/ssdt_ohio/tools/ant/antlib.xml --- a/src/org/ssdt_ohio/tools/ant/antlib.xml Sat Apr 16 16:22:27 2011 -0400 +++ b/src/org/ssdt_ohio/tools/ant/antlib.xml Tue Jun 07 18:06:07 2011 -0400 @@ -1,3 +1,4 @@ + \ No newline at end of file diff -r 82fc5e17cc59 -r 09f9f3d5c507 src/org/ssdt_ohio/tools/ant/wsd2html.xsl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/org/ssdt_ohio/tools/ant/wsd2html.xsl Tue Jun 07 18:06:07 2011 -0400 @@ -0,0 +1,482 @@ + + + + + + + + + + + + + + + + + + Web Service Description: <xsl:value-of select="wsdl:definitions/wsdl:service/@name"/> + + + + + +

Web Service Description: +

+

Contents

+ +
+ + + + + + +
+ + + +
+ +

Namespaces:

+ + + + + + + + + + + + +
PrefixNamespace
+ + + + + + [Default] + + + + +
+ +

Imported Schemas

+ + + + + + + + + + + + +
NamespaceLocation
+ + + +
+ +
+ +

Port Type: +

+ + +

Operations Detail

+ + + + +
+

Messsages

+ + + + + +
MessageParameter
+ +
+

Elements

+
    + + + +
+ + + + +
+

Types

+
    + + + +
+
+ + + + + +
+ Generated by + + +
+ + + +

Operation: +

+ + + + + + + + + + + + + + + + + + + +
Input + + + +
Output + + + +
Fault + + + + + + + + + + + + + + + + + + + +
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + []: + + + []: + + + + + + + + + + + + + + + + + + +
  • +
    + + + + + + + + + + + + + + + + +

    + +

    +
    + +
    +
    + + + + + + + + + + + + + + + +
  • + + + + + + + + + + + + + + + + + +

    + +

    +
    + +
    +
    + + +

    Service Summary: Service: +

    + +

    Port name: +
    + Endpoint URL: +
    + Binding: +

    +
    +
    + + + Operations: + + + + + + + + + + + +
    OperationDescription
    + + + + + + + +
    +
    + + + + + + + + + + + . + + + + + +
      +
    • +

      + + + +

      +
    • +
    +
    + +
      +
    • < + + =" + " + + + + /> + + + > + + + + </> + + +
    • +
    +
    +
    +
    + + + + + + + + + + + + + +
    \ No newline at end of file