annotate src/org/ssdt_ohio/tools/ant/WsdlSetup.java @ 2:09f9f3d5c507

CM-127: Move wsdlsetup and wsd2html.xsl from Tools
author smith@nwoca.org
date Tue, 07 Jun 2011 18:06:07 -0400
parents
children
rev   line source
2
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
1 /* Copyright 2003 Ohio Department of Education, Office of Information Technology,
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
2 * 25 South Front St, Columbus, Ohio 43215, U.S.A., All Rights Reserved.
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
3 */
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
4 package org.ssdt_ohio.tools.ant;
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
5
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
6 import java.io.File;
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
7
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
8 import java.util.ArrayList;
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
9 import java.util.Iterator;
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
10 import java.util.List;
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
11 import javax.xml.parsers.DocumentBuilderFactory;
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
12 import javax.xml.transform.Transformer;
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
13 import javax.xml.transform.TransformerFactory;
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
14 import javax.xml.transform.dom.DOMSource;
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
15 import javax.xml.transform.stream.StreamResult;
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
16
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
17 import org.apache.tools.ant.BuildException;
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
18 import org.apache.tools.ant.Task;
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
19
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
20 import org.w3c.dom.Document;
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
21 import org.w3c.dom.Element;
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
22 import org.w3c.dom.Node;
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
23 import org.w3c.dom.NodeList;
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
24
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
25 import java.util.regex.Pattern;
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
26
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
27 /** Simple ant task for maniuplating WSDL settings.
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
28 *
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
29 *
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
30 * @author smith
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
31 * @since 2007-8-1
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
32 */
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
33 public class WsdlSetup
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
34 extends Task {
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
35
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
36 private static final String SCHEMA_NS = "http://www.w3.org/2001/XMLSchema";
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
37 private static final String OECNRPC_NS = "http://xml.ssdt.nwoca.org/OECN-RPC/10";
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
38 private final List locations = new ArrayList(); /* Store locations */
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
39
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
40 private String file;
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
41 private String destfile;
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
42 private String typesFile;
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
43 private String typesPattern = ".*Fault$";
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
44 private boolean elementFormDefaultQualified = true;
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
45
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
46 public void execute() {
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
47 if (file == null) {
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
48 throw new BuildException("must specify 'file' as input file");
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
49 }
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
50
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
51 if (destfile == null) {
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
52 throw new BuildException("must specify 'destfile' as output file");
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
53 }
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
54
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
55 try {
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
56 DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
57 dbf.setNamespaceAware(true);
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
58
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
59 Document wsdl = dbf.newDocumentBuilder().parse(new File(getFile()));
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
60 NodeList imports = wsdl.getElementsByTagNameNS(SCHEMA_NS, "import");
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
61
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
62 for (int i = 0; i < imports.getLength(); i++) {
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
63 replaceLocations((Element) imports.item(i));
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
64 }
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
65
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
66 TransformerFactory tFactory = TransformerFactory.newInstance();
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
67 Transformer transformer = tFactory.newTransformer();
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
68 DOMSource source = new DOMSource(wsdl);
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
69 StreamResult result = new StreamResult(new File(getDestfile()));
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
70 transformer.transform(source, result);
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
71
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
72 if (typesFile != null) {
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
73 generateTypesSchema(wsdl);
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
74 }
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
75 } catch (javax.xml.parsers.ParserConfigurationException e) {
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
76 throw new BuildException(e);
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
77 } catch (org.xml.sax.SAXException e) {
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
78 throw new BuildException(e);
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
79 } catch (java.io.IOException e) {
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
80 throw new BuildException(e);
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
81 } catch (javax.xml.transform.TransformerException e) {
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
82 throw new BuildException(e);
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
83 }
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
84 }
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
85
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
86 private void replaceLocations(Element imp) {
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
87 String ns = imp.getAttribute("namespace");
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
88
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
89 for (Iterator it = locations.iterator(); it.hasNext();) {
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
90 SchemaLocation loc = (SchemaLocation) it.next();
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
91
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
92 if (ns.equals(loc.getNamespace())) {
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
93 imp.setAttribute("schemaLocation", loc.getLocation());
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
94 }
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
95 }
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
96 }
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
97
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
98 private void generateTypesSchema(Document wsdl)
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
99 throws BuildException {
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
100 try {
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
101 DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
102 dbf.setNamespaceAware(true);
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
103
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
104 Document schema = dbf.newDocumentBuilder().newDocument();
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
105 Element root = (Element) wsdl.getElementsByTagNameNS(SCHEMA_NS,
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
106 "schema").item(0);
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
107 String targetNamespace = root.getAttribute("targetNamespace");
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
108
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
109 schema.appendChild(schema.importNode(root, true));
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
110 root = schema.getDocumentElement();
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
111 root.setAttribute("xmlns:xsd", SCHEMA_NS);
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
112 if (isElementFormDefaultQualified()) {
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
113 root.setAttribute("elementFormDefault", "qualified");
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
114 }
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
115 root.setAttribute("xmlns", targetNamespace);
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
116 root.setAttribute("xmlns:oecnrpc", OECNRPC_NS);
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
117
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
118 for (Iterator it = locations.iterator(); it.hasNext();) {
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
119 SchemaLocation loc = (SchemaLocation) it.next();
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
120
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
121 if (loc.getPrefix() != null) {
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
122 root.setAttribute("xmlns:" + loc.getPrefix(), loc.getNamespace());
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
123 }
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
124 }
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
125
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
126 // Remove everything except the included types.
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
127 boolean done = false;
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
128
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
129 Pattern typesPat = Pattern.compile(getTypesPattern());
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
130
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
131 while (!done) {
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
132 done = true;
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
133
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
134 NodeList children = root.getChildNodes();
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
135
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
136 for (int i = 0; i < children.getLength(); i++) {
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
137 if (children.item(i).getNodeType() == Node.ELEMENT_NODE) {
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
138 Element e = (Element) children.item(i);
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
139
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
140 if (!e.getLocalName().equals("import") && !typesPat.matcher(e.
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
141 getAttribute("name")).matches()) {
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
142 root.removeChild(e);
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
143 done = false;
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
144 }
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
145 }
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
146 }
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
147 }
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
148 TransformerFactory tFactory = TransformerFactory.newInstance();
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
149 Transformer transformer = tFactory.newTransformer();
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
150
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
151 DOMSource source = new DOMSource(schema);
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
152 StreamResult result = new StreamResult(new File(getTypesFile()));
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
153 transformer.transform(source, result);
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
154 } catch (Exception e) {
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
155 throw new BuildException(e);
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
156 }
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
157 }
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
158
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
159 public SchemaLocation createSchemaLocation() {
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
160 SchemaLocation loc = new SchemaLocation();
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
161 locations.add(loc);
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
162
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
163 return loc;
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
164 }
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
165
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
166 /**
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
167 * Getter for property file.
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
168 * @return Value of property file.
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
169 */
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
170 public java.lang.String getFile() {
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
171 return file;
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
172 }
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
173
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
174 /**
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
175 * Setter for property file.
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
176 * @param file New value of property file.
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
177 */
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
178 public void setFile(java.lang.String file) {
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
179 this.file = file;
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
180 }
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
181
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
182 /**
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
183 * Getter for property destfile.
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
184 * @return Value of property destfile.
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
185 */
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
186 public java.lang.String getDestfile() {
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
187 return destfile;
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
188 }
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
189
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
190 /**
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
191 * Setter for property destfile.
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
192 * @param destfile New value of property destfile.
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
193 */
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
194 public void setDestfile(java.lang.String destfile) {
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
195 this.destfile = destfile;
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
196 }
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
197
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
198 /**
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
199 * Getter for property typesFile.
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
200 * @return Value of property typesFile.
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
201 */
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
202 public java.lang.String getTypesFile() {
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
203 return typesFile;
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
204 }
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
205
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
206 /**
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
207 * Setter for property typesFile.
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
208 * @param typesFile New value of property typesFile.
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
209 */
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
210 public void setTypesFile(java.lang.String typesFile) {
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
211 this.typesFile = typesFile;
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
212 }
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
213
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
214 /**
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
215 * @return the elementFormDefaultQualified
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
216 */
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
217 public boolean isElementFormDefaultQualified() {
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
218 return elementFormDefaultQualified;
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
219 }
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
220
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
221 /**
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
222 * @param elementFormDefaultQualified the elementFormDefaultQualified to set
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
223 */
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
224 public void setElementFormDefaultQualified(boolean elementFormDefaultQualified) {
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
225 this.elementFormDefaultQualified = elementFormDefaultQualified;
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
226 }
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
227
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
228 /** A nested 'schemaLocation' object. */
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
229 public class SchemaLocation {
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
230
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
231 private String namespace;
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
232 private String location;
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
233 private String prefix;
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
234
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
235 public SchemaLocation() {
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
236 }
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
237
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
238 public java.lang.String getNamespace() {
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
239 return namespace;
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
240 }
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
241
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
242 public void setNamespace(java.lang.String namespace) {
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
243 this.namespace = namespace;
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
244 }
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
245
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
246 public java.lang.String getLocation() {
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
247 return location;
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
248 }
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
249
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
250 public void setLocation(java.lang.String location) {
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
251 this.location = location;
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
252 }
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
253
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
254 public String getPrefix() {
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
255 return prefix;
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
256 }
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
257
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
258 public void setPrefix(String prefix) {
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
259 this.prefix = prefix;
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
260 }
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
261 }
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
262
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
263 public String getTypesPattern() {
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
264 return typesPattern;
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
265 }
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
266
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
267 public void setTypesPattern(String typesPattern) {
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
268 this.typesPattern = typesPattern;
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
269 }
09f9f3d5c507 CM-127: Move wsdlsetup and wsd2html.xsl from Tools
smith@nwoca.org
parents:
diff changeset
270 }