You are viewing a plain text version of this content. The canonical link for it is here.
Posted to woden-dev@ws.apache.org by jk...@apache.org on 2005/06/30 17:20:40 UTC
svn commit: r208636 -
/incubator/woden/java/src/org/apache/woden/internal/DOMWSDLReader.java
Author: jkaputin
Date: Thu Jun 30 08:20:38 2005
New Revision: 208636
URL: http://svn.apache.org/viewcvs?rev=208636&view=rev
Log:
More parse description code
Modified:
incubator/woden/java/src/org/apache/woden/internal/DOMWSDLReader.java
Modified: incubator/woden/java/src/org/apache/woden/internal/DOMWSDLReader.java
URL: http://svn.apache.org/viewcvs/incubator/woden/java/src/org/apache/woden/internal/DOMWSDLReader.java?rev=208636&r1=208635&r2=208636&view=diff
==============================================================================
--- incubator/woden/java/src/org/apache/woden/internal/DOMWSDLReader.java (original)
+++ incubator/woden/java/src/org/apache/woden/internal/DOMWSDLReader.java Thu Jun 30 08:20:38 2005
@@ -6,6 +6,7 @@
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
+import java.util.Map;
import javax.xml.namespace.QName;
import javax.xml.parsers.DocumentBuilder;
@@ -17,8 +18,11 @@
import org.apache.woden.internal.util.dom.QNameUtils;
import org.apache.woden.internal.wsdl20.Constants;
import org.apache.woden.wsdl20.xml.DescriptionElement;
+import org.apache.woden.wsdl20.xml.ImportElement;
+import org.w3c.dom.Attr;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
@@ -56,7 +60,7 @@
inputStream.close();
Element docEl = doc.getDocumentElement();
- DescriptionElement desc = parseDescription(url.toString(), docEl);
+ DescriptionElement desc = parseDescription(url.toString(), docEl, null);
return desc;
} catch (Exception e) {
@@ -71,28 +75,81 @@
throw e;
}
}
-
- private DescriptionElement parseDescription(String documentBaseURI, Element docEl)
- throws WSDLException {
-
- checkElementName(docEl, Constants.Q_ELEM_DESCRIPTION);
+
+ private DescriptionElement parseDescription(String documentBaseURI,
+ Element descEl,
+ Map importedDescs)
+ throws WSDLException
+ {
+ checkElementName(descEl, Constants.Q_ELEM_DESCRIPTION);
DescriptionElement desc =
((DOMWSDLFactory)getFactory()).newDescription();
+
+ desc.setDocumentBaseURI(documentBaseURI);
- //TODO set extension registry
+ //TODO set extension registry here or let factory set it in newDescription?
- String targetNamespace =
- DOMUtils.getAttribute(docEl, Constants.ATTR_TARGET_NAMESPACE);
+ //parse target namespace attribute
+ String targetNamespace =
+ DOMUtils.getAttribute(descEl, Constants.ATTR_TARGET_NAMESPACE);
desc.setTargetNamespace(targetNamespace);
- //TODO - remaining child elements,
+ //parse the namespace declarations
+
+ NamedNodeMap attrs = descEl.getAttributes();
+
+ int size = attrs.getLength();
+
+ for (int i = 0; i < size; i++)
+ {
+ Attr attr = (Attr)attrs.item(i);
+ String namespaceURI = attr.getNamespaceURI();
+ String localPart = attr.getLocalName();
+ String value = attr.getValue();
+
+ if (namespaceURI != null && namespaceURI.equals(Constants.NS_URI_XMLNS))
+ {
+ if (localPart != null && !localPart.equals(Constants.ATTR_XMLNS))
+ {
+ desc.addNamespace(localPart, value); //a prefixed namespace
+ }
+ else
+ {
+ desc.addNamespace(null, value); //the default namespace
+ }
+ }
+ }
+
+ //Parse the child elements of the description.
+ //Per the WSDL 2.0 spec, they must be in the following order if present:
+ //<document>
+ //<import> <include> or WSDL extension elements in any order
+ //<types>
+ //<interface> <binding> <service> or WSDL extension elements in any order.
+
+ Element tempEl = DOMUtils.getFirstChildElement(descEl);
+
+ while (tempEl != null)
+ {
+ //TODO child elements
+
+ tempEl = DOMUtils.getNextSiblingElement(tempEl);
+ }
return desc;
}
-
+ private ImportElement parseImport(String documentBaseURI,
+ Element importEl,
+ Map importedDescs)
+ throws WSDLException
+ {
+ //TODO complete this method
+ return null;
+ }
+
/**
* Check the actual element encountered against the expected qname
*
@@ -106,30 +163,29 @@
if (!QNameUtils.matches(qname, el))
{
getErrorReporter().reportError(
- "WSDL004",
- new Object[] {qname, QNameUtils.newQName(el)},
- ErrorReporter.SEVERITY_FATAL_ERROR);
-
+ "WSDL004",
+ new Object[] {qname, QNameUtils.newQName(el)},
+ ErrorReporter.SEVERITY_FATAL_ERROR);
+
//TODO wsdlExc.setLocation(XPathUtils.getXPathExprFromNode(el));
-
+
}
}
-
-
- private Document getDocument(InputSource inputSource, String desc) {
+ private Document getDocument(InputSource inputSource, String desc)
+ {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
-
+
factory.setNamespaceAware(true);
factory.setValidating(false);
-
+
Document doc = null;
-
- try {
+ try {
+
DocumentBuilder builder = factory.newDocumentBuilder();
doc = builder.parse(inputSource);
-
+
} catch (ParserConfigurationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
@@ -140,12 +196,10 @@
// TODO Auto-generated catch block
e.printStackTrace();
}
-
+
//TODO - potentially returns null. correct after deciding how
//to handle exceptions (e.g. return inside try block).
return doc;
}
-
-
}
---------------------------------------------------------------------
To unsubscribe, e-mail: woden-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: woden-dev-help@ws.apache.org