Author: jdoyle
Date: 2009-06-09 21:48:53 -0400 (Tue, 09 Jun 2009)
New Revision: 1033
Added:
branches/6.1.x/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/cache/CachingOutputStream.java
Modified:
branches/6.1.x/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/base/ExecutionInfo.java
branches/6.1.x/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/cache/CachingInputStreamFilter.java
branches/6.1.x/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/soap/SOAPDocBuilder.java
branches/6.1.x/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/soap/SOAPExecutor.java
branches/6.1.x/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/streaming/ElementProcessor.java
branches/6.1.x/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/streaming/StreamingMultiPathFilter.java
branches/6.1.x/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/streaming/StreamingResultsProducer.java
branches/6.1.x/connectors/connector-xml/src/test/java/com/metamatrix/connector/xml/TestElementCollector.java
Log:
TEIID-647
SOAP Relational connector is not returning data from service.
Modified:
branches/6.1.x/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/base/ExecutionInfo.java
===================================================================
---
branches/6.1.x/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/base/ExecutionInfo.java 2009-06-09
18:11:52 UTC (rev 1032)
+++
branches/6.1.x/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/base/ExecutionInfo.java 2009-06-10
01:48:53 UTC (rev 1033)
@@ -57,6 +57,8 @@
private Properties m_schemaProps;
private String m_tablePath;
private String m_location;
+ private Map<String, String> m_prefixToNamespace;
+ private Map<String, String> m_namespaceToPrefix;
public ExecutionInfo() {
m_columnCount = 0;
@@ -159,42 +161,58 @@
return result;
}
- public Map<String, String> getNamespaces() throws ConnectorException {
- Map<String, String> result = new HashMap<String, String>();
- String namespacePrefixes = getOtherProperties().getProperty(
- Constants.NAMESPACE_PREFIX_PROPERTY_NAME);
- if (namespacePrefixes == null || namespacePrefixes.trim().length() == 0) {
- return null;
- }
- String prefix = null;
- String uri = null;
- try {
- String xml = "<e " + namespacePrefixes + "/>";
//$NON-NLS-1$ //$NON-NLS-2$
- Reader reader = new StringReader(xml);
- SAXBuilder builder = new SAXBuilder();
- Document domDoc = builder.build(reader);
- Element elem = domDoc.getRootElement();
- List namespaces = elem.getAdditionalNamespaces();
- for (Iterator iter = namespaces.iterator(); iter.hasNext();) {
- Object o = iter.next();
- Namespace namespace = (Namespace) o;
- prefix = namespace.getPrefix();
- uri = namespace.getURI();
- result.put(prefix, uri);
- }
- } catch (JDOMException e) {
- String rawMsg = Messages
- .getString("Executor.jaxen.error.on.namespace.pairs");
//$NON-NLS-1$
- Object[] objs = new Object[2];
- objs[0] = prefix;
- objs[1] = uri;
- String msg = MessageFormat.format(rawMsg, objs);
- throw new ConnectorException(e, msg);
- } catch (IOException e) {
- throw new ConnectorException(e, e.getMessage());
- }
- return result;
+ public Map<String, String> getNamespaceToPrefixMap() throws ConnectorException {
+ if(null != m_namespaceToPrefix) {
+ return m_namespaceToPrefix;
+ } else {
+ getPrefixToNamespacesMap();
+ return m_namespaceToPrefix;
+ }
}
+
+ public Map<String, String> getPrefixToNamespacesMap() throws ConnectorException {
+ if (null != m_prefixToNamespace) {
+ return m_prefixToNamespace;
+ } else {
+ m_prefixToNamespace = new HashMap<String, String>();
+ m_namespaceToPrefix = new HashMap<String, String>();
+ String namespacePrefixes = getOtherProperties().getProperty(
+ Constants.NAMESPACE_PREFIX_PROPERTY_NAME);
+ if (namespacePrefixes == null
+ || namespacePrefixes.trim().length() == 0) {
+ return null;
+ }
+ String prefix = null;
+ String uri = null;
+ try {
+ String xml = "<e " + namespacePrefixes + "/>";
//$NON-NLS-1$ //$NON-NLS-2$
+ Reader reader = new StringReader(xml);
+ SAXBuilder builder = new SAXBuilder();
+ Document domDoc = builder.build(reader);
+ Element elem = domDoc.getRootElement();
+ List namespaces = elem.getAdditionalNamespaces();
+ for (Iterator iter = namespaces.iterator(); iter.hasNext();) {
+ Object o = iter.next();
+ Namespace namespace = (Namespace) o;
+ prefix = namespace.getPrefix();
+ uri = namespace.getURI();
+ m_prefixToNamespace.put(prefix, uri);
+ m_namespaceToPrefix.put(uri, prefix);
+ }
+ } catch (JDOMException e) {
+ String rawMsg = Messages
+ .getString("Executor.jaxen.error.on.namespace.pairs"); //$NON-NLS-1$
+ Object[] objs = new Object[2];
+ objs[0] = prefix;
+ objs[1] = uri;
+ String msg = MessageFormat.format(rawMsg, objs);
+ throw new ConnectorException(e, msg);
+ } catch (IOException e) {
+ throw new ConnectorException(e, e.getMessage());
+ }
+ return m_prefixToNamespace;
+ }
+ }
public void setSchemaProperties(Properties schemaProperties) {
m_schemaProps = schemaProperties;
Modified:
branches/6.1.x/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/cache/CachingInputStreamFilter.java
===================================================================
---
branches/6.1.x/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/cache/CachingInputStreamFilter.java 2009-06-09
18:11:52 UTC (rev 1032)
+++
branches/6.1.x/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/cache/CachingInputStreamFilter.java 2009-06-10
01:48:53 UTC (rev 1033)
@@ -65,6 +65,7 @@
private void chunk() {
if(!idCached) {
context.put(requestId, Boolean.TRUE);
+ idCached = true;
}
if(buff.length() >= 2560) {
Added:
branches/6.1.x/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/cache/CachingOutputStream.java
===================================================================
---
branches/6.1.x/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/cache/CachingOutputStream.java
(rev 0)
+++
branches/6.1.x/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/cache/CachingOutputStream.java 2009-06-10
01:48:53 UTC (rev 1033)
@@ -0,0 +1,67 @@
+package com.metamatrix.connector.xml.cache;
+
+import java.io.IOException;
+import java.io.OutputStream;
+
+import org.teiid.connector.api.ExecutionContext;
+
+public class CachingOutputStream extends OutputStream {
+
+ private ExecutionContext context;
+ private String requestId;
+ private Integer chunkIndex;
+ private boolean idCached = false;
+ private StringBuffer buff;
+
+ public CachingOutputStream(ExecutionContext context, String requestId) {
+ super();
+ this.context = context;
+ this.requestId = requestId;
+ chunkIndex = Integer.valueOf(0);
+ buff = new StringBuffer();
+ }
+
+ @Override
+ public void write(int b) throws IOException {
+ buff.append((char)b);
+ chunk();
+ }
+
+
+ @Override
+ public void flush() throws IOException {
+ super.flush();
+ if(buff.length()!= 0) {
+ context.put(requestId + chunkIndex.toString(), buff.toString());
+ chunkIndex++;
+ buff = new StringBuffer();
+ }
+ }
+
+ @Override
+ public void close() throws IOException {
+ flush();
+ super.close();
+ }
+
+ /**
+ * 8192 * 5 / 16
+ * 1kb * 5 / 16 bit chars = 2560 chars
+ */
+ private void chunk() {
+ if(!idCached) {
+ context.put(requestId, Boolean.TRUE);
+ idCached = true;
+ }
+
+ if(buff.length() >= 2560) {
+ context.put(requestId + chunkIndex.toString(), buff.toString());
+ chunkIndex++;
+ buff = new StringBuffer();
+ }
+ }
+
+ public CachedXMLStream getCachedXMLStream() {
+ return new CachedXMLStream(context, requestId);
+ }
+}
Modified:
branches/6.1.x/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/soap/SOAPDocBuilder.java
===================================================================
---
branches/6.1.x/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/soap/SOAPDocBuilder.java 2009-06-09
18:11:52 UTC (rev 1032)
+++
branches/6.1.x/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/soap/SOAPDocBuilder.java 2009-06-10
01:48:53 UTC (rev 1033)
@@ -258,18 +258,32 @@
return builder.buildDocument(params, "SOAP-ENV:Header", namespacePrefixes);
}
- public Document createXMLRequestDoc(List params, SOAPConnectorState state, String
namespacePrefixes, String inputParmsXPath) throws ConnectorException {
- DocumentBuilder builder = new DocumentBuilder();
- builder.setUseTypeAttributes(state.isEncoded());
- //use dummy root if there is none
- final String slash = "/";
- final String dotSlash = "./";
- if(inputParmsXPath.equals(dotSlash) || inputParmsXPath.equals(slash) ||
inputParmsXPath.equals("")) {
- inputParmsXPath = SOAPDocBuilder.DUMMY_NS_PREFIX + ":dummy";
- namespacePrefixes = namespacePrefixes + " xmlns:" +
SOAPDocBuilder.DUMMY_NS_PREFIX + "=\"" + SOAPDocBuilder.DUMMY_NS_NAME +
"\"";
- }
- return builder.buildDocument(params, inputParmsXPath, namespacePrefixes);
- }
+ public Document createXMLRequestDoc(List params, SOAPConnectorState state,
+ String namespacePrefixes, String inputParmsXPath)
+ throws ConnectorException {
+ Document doc;
+ DocumentBuilder builder = new DocumentBuilder();
+ builder.setUseTypeAttributes(state.isEncoded());
+ final String slash = "/";
+ final String dotSlash = "./";
+ boolean hasDummy = false;
+ if (inputParmsXPath.equals(dotSlash) || inputParmsXPath.equals(slash)
+ || inputParmsXPath.equals("")) {
+ inputParmsXPath = SOAPDocBuilder.DUMMY_NS_PREFIX + ":dummy";
+ namespacePrefixes = namespacePrefixes + " xmlns:"
+ + SOAPDocBuilder.DUMMY_NS_PREFIX + "=\""
+ + SOAPDocBuilder.DUMMY_NS_NAME + "\"";
+ hasDummy = true;
+ }
+ doc = builder.buildDocument(params, inputParmsXPath, namespacePrefixes);
+ if (hasDummy) {
+ // Since there is no real root - these should all be elements
+ Element element = (Element) doc.getRootElement().getChildren().get(0);
+ element.detach();
+ doc = new Document(element);
+ }
+ return doc;
+ }
private static void handleSoapFault(Element soapFault, SOAPConnectorState state)
throws ConnectorException {
String strMessage = soapFault.getChildTextTrim("faultstring");
//$NON-NLS-1$
Modified:
branches/6.1.x/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/soap/SOAPExecutor.java
===================================================================
---
branches/6.1.x/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/soap/SOAPExecutor.java 2009-06-09
18:11:52 UTC (rev 1032)
+++
branches/6.1.x/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/soap/SOAPExecutor.java 2009-06-10
01:48:53 UTC (rev 1033)
@@ -24,13 +24,11 @@
package com.metamatrix.connector.xml.soap;
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
import java.io.InputStream;
+import java.io.StringReader;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
-import java.util.Properties;
import javax.xml.namespace.QName;
import javax.xml.transform.Source;
@@ -43,11 +41,9 @@
import javax.xml.ws.soap.SOAPBinding;
import org.jdom.Document;
-import org.jdom.Element;
-import org.jdom.output.DOMOutputter;
+import org.jdom.output.XMLOutputter;
import org.teiid.connector.api.ConnectorEnvironment;
import org.teiid.connector.api.ConnectorException;
-import org.w3c.dom.NodeList;
import com.metamatrix.connector.xml.Constants;
import com.metamatrix.connector.xml.SOAPConnectorState;
@@ -58,13 +54,15 @@
import com.metamatrix.connector.xml.base.DocumentBuilder;
import com.metamatrix.connector.xml.base.ExecutionInfo;
import com.metamatrix.connector.xml.base.RequestGenerator;
+import com.metamatrix.connector.xml.cache.CachingOutputStream;
import com.metamatrix.connector.xml.http.HTTPExecutor;
import com.metamatrix.connector.xmlsource.soap.SecurityToken;
public class SOAPExecutor extends HTTPExecutor {
SecurityToken secToken;
- NodeList requestNodes;
+ XMLOutputter xmlOutputter = new XMLOutputter();
+ Document doc;
public SOAPExecutor(SOAPConnectorState state, XMLExecution execution, ExecutionInfo
exeInfo) throws ConnectorException {
super((XMLConnectorState)state, execution, exeInfo);
@@ -74,16 +72,10 @@
try {
TrustedPayloadHandler handler = execution.getConnection().getTrustedPayloadHandler();
ConnectorEnvironment env = execution.getConnection().getConnectorEnv();
- Properties schemaProperties = getExeInfo().getSchemaProperties();
secToken = SecurityToken.getSecurityToken(env, handler);
-
- QName svcQname = new QName(
- schemaProperties.getProperty(Constants.SERVICE_NAMESPACE),
- schemaProperties.getProperty(Constants.SERVICE_NAME));
- QName portQName = new QName(
- schemaProperties.getProperty(Constants.PORT_NAMESPACE),
- schemaProperties.getProperty(Constants.PORT_NAME));
+ QName svcQname = new QName("http://org.apache.cxf",
"foo");
+ QName portQName = new QName("http://org.apache.cxf",
"bar");
Service svc = Service.create(svcQname);
svc.addPort(
portQName,
@@ -94,35 +86,24 @@
portQName,
Source.class,
Service.Mode.PAYLOAD);
-
- StringBuffer buffer = new StringBuffer();
- for (int j = 0; j < requestNodes.getLength(); j++) {
- org.w3c.dom.Element child = (org.w3c.dom.Element) requestNodes.item(j);
- buffer.append(child.getNodeValue());
- }
- ByteArrayInputStream bais = new
ByteArrayInputStream(buffer.toString().getBytes());
- Source input = new StreamSource(bais);
+ StringReader reader = new StringReader(xmlOutputter.outputString(doc));
+ Source input = new StreamSource(reader);
// Invoke the operation.
Source output = dispatch.invoke(input);
-
+
// Process the response.
- StreamResult result = new StreamResult(new ByteArrayOutputStream());
+ CachingOutputStream out = new CachingOutputStream(execution.getExeContext(),
getCacheKey());
+ StreamResult result = new StreamResult(out);
Transformer trans = TransformerFactory.newInstance().newTransformer();
trans.transform(output, result);
- ByteArrayOutputStream baos = (ByteArrayOutputStream)
result.getOutputStream();
-
- // Write out the response content.
- String responseContent = new String(baos.toByteArray());
- System.out.println(responseContent);
-
- return null;
+ return out.getCachedXMLStream();
} catch (Exception e) {
throw new ConnectorException(e);
}
}
- protected void createRequest(List params)
+ protected void setRequests(List params, String uriString)
throws ConnectorException {
SOAPConnectorState state = (SOAPConnectorState) getState();
@@ -139,24 +120,10 @@
String namespacePrefixes =
getExeInfo().getOtherProperties().getProperty(Constants.NAMESPACE_PREFIX_PROPERTY_NAME);
String inputParmsXPath =
getExeInfo().getOtherProperties().getProperty(DocumentBuilder.PARM_INPUT_XPATH_TABLE_PROPERTY_NAME);
SOAPDocBuilder builder = new SOAPDocBuilder();
- Document doc = builder.createXMLRequestDoc(bodyParams, (SOAPConnectorState)getState(),
namespacePrefixes, inputParmsXPath);
- Element docRoot = doc.getRootElement();
- DOMOutputter domOutputter = new DOMOutputter();
- try {
- if (docRoot.getNamespaceURI().equals(SOAPDocBuilder.DUMMY_NS_NAME)) {
- // Since there is no real root - these should all be elements
- org.w3c.dom.Document dummyNode = domOutputter.output(doc);
- requestNodes = dummyNode.getChildNodes().item(0).getChildNodes();
- } else {
- org.w3c.dom.Document document = domOutputter.output(doc);
- requestNodes = document.getChildNodes();
- }
- } catch (Exception e) {
- throw new ConnectorException(e);
- }
+ doc = builder.createXMLRequestDoc(bodyParams, (SOAPConnectorState)getState(),
namespacePrefixes, inputParmsXPath);
}
- protected String getCacheKey(int i) throws ConnectorException {
+ protected String getCacheKey() throws ConnectorException {
StringBuffer cacheKey = new StringBuffer();
cacheKey.append("|"); //$NON-NLS-1$
cacheKey.append(execution.getConnection().getUser());
@@ -164,11 +131,8 @@
cacheKey.append(execution.getConnection().getQueryId());
cacheKey.append("|");
cacheKey.append(buildUriString());
- cacheKey.append("|"); //$NON-NLS-1$
- for (int j = 0; j < requestNodes.getLength(); j++) {
- org.w3c.dom.Element child = (org.w3c.dom.Element) requestNodes.item(j);
- cacheKey.append(child.toString());
- }
+ //cacheKey.append("|"); //$NON-NLS-1$
+ //cacheKey.append(xmlOutputter.outputString(doc));
return cacheKey.toString();
}
Modified:
branches/6.1.x/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/streaming/ElementProcessor.java
===================================================================
---
branches/6.1.x/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/streaming/ElementProcessor.java 2009-06-09
18:11:52 UTC (rev 1032)
+++
branches/6.1.x/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/streaming/ElementProcessor.java 2009-06-10
01:48:53 UTC (rev 1033)
@@ -31,10 +31,12 @@
private Object[] row;
private Map<String, OutputXPathDesc> resultPaths;
private OutputXPathDesc cacheKeyColumn;
+ private Map<String, String> namespacesToPrefixMap;
public ElementProcessor(ExecutionInfo info) throws ConnectorException {
this.info = info;
resultPaths = generateXPaths();
+ namespacesToPrefixMap = info.getNamespaceToPrefixMap();
}
/**
@@ -76,12 +78,16 @@
* @param path
*/
private void listChildren(Node current, String path) {
-
+
+ if(current.getDocument().equals(current.getParent())) {
+ path = getLocalQName(current);
+ }
+
if (current instanceof Element) {
Element temp = (Element) current;
for (int i = 0; i < temp.getAttributeCount(); i++) {
Attribute attribute = temp.getAttribute(i);
- String attrPath = path + '@' + attribute.getQualifiedName();
+ String attrPath = path + "/@" + getLocalQName(attribute);
if(resultPaths.containsKey(attrPath)) {
getColumn(attribute, attrPath);
}
@@ -108,15 +114,45 @@
if (next instanceof Element) {
Element temp = (Element) next;
if(path.isEmpty()) {
- childPath = temp.getQualifiedName();
+ childPath = getLocalQName(temp);
} else {
- childPath= path + '/' + temp.getQualifiedName();
+ childPath= path + '/' + getLocalQName(temp);
}
}
listChildren(next, childPath);
}
}
+ /**
+ * Get the qualified name for the Element, but replace the prefixes
+ * from the actual doc with the matching prefix from the model. Without
+ * this prefix we can't do a proper path comparison.
+ * @throws ConnectorException
+ */
+ private String getLocalQName(Node node) {
+ String namespaceURI = null;
+ String localName = null;
+ if(node instanceof Element) {
+ Element element = (Element)node;
+ namespaceURI = element.getNamespaceURI();
+ localName = element.getLocalName();
+ } else if (node instanceof Attribute) {
+ Attribute attribute = (Attribute)node;
+ namespaceURI = attribute.getNamespaceURI();
+ localName = attribute.getLocalName();
+ }
+ if(null == namespaceURI) {
+ throw new Error("namespce URI not found in model namespaces");
+ }
+ String prefix = namespacesToPrefixMap.get(namespaceURI);
+ String result;
+ if(null == prefix) {
+ result = localName;
+ } else {
+ result = prefix + ':' + localName;
+ }
+ return result;
+ }
private void getColumn(Node node, String path) {
OutputXPathDesc columnMetadata = resultPaths.get(path);
Modified:
branches/6.1.x/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/streaming/StreamingMultiPathFilter.java
===================================================================
---
branches/6.1.x/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/streaming/StreamingMultiPathFilter.java 2009-06-09
18:11:52 UTC (rev 1032)
+++
branches/6.1.x/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/streaming/StreamingMultiPathFilter.java 2009-06-10
01:48:53 UTC (rev 1033)
@@ -29,7 +29,6 @@
}
private PathPackage getPathPackage(String locationPath, Map<String, String>
prefixes) throws InvalidPathException {
- // copied from nux.xom.xquery.StreamingPathFilter
if (locationPath == null)
throw new InvalidPathException("locationPath must not be null");
if (locationPath.indexOf("//") >= 0)
@@ -76,10 +75,10 @@
} // end if
localNames[i] = localNames[i].substring(k + 1).trim();
- if (localNames[i].equals("*")) {
+ //if (localNames[i].equals("*")) {
// localName is irrelevant (does not matter)
- localNames[i] = null;
- }
+ // localNames[i] = null;
+ //}
}
return new PathPackage(localNames, namespaceURIs);
}
@@ -141,6 +140,10 @@
@Override
public Nodes finishMakingElement(Element elem) {
if (level == 0) {
+ // check for / match
+ if (pathPackages.isMatch(level,elem.getQualifiedName(), elem.getNamespaceURI())) {
+ return transformMatch(elem);
+ } //causes nu.xom.WellformednessException: Factory attempted to remove the root
element on the request
mismatch = null;
level--;
return super.finishMakingElement(elem);
@@ -165,10 +168,14 @@
level--;
if (transform == null) return super.finishMakingElement(elem);
Nodes results = transform.transform(elem);
-
- for (int i = results.size(); --i >= 0; ) {
- Node node = results.get(i);
- if (node != elem) node.detach();
+
+ if(results.size() == 0) {
+ results = new Nodes(elem);
+ } else {
+ for (int i = results.size(); --i >= 0; ) {
+ Node node = results.get(i);
+ if (node != elem) node.detach();
+ }
}
return results;
}
@@ -269,9 +276,13 @@
public boolean isRequired(int level, String localName, String namespaceURI) {
String name = localNames[level];
String uri = namespaceURIs[level];
+ if(level == 0 && name.equals("*")) {
+ return true;
+ } else {
return
(name == null || name.equals(localName)) &&
(uri == null || uri.equals(namespaceURI));
+ }
}
public boolean hasLevelMatch(int level) {
@@ -279,8 +290,10 @@
}
public boolean isMatch(int level, String localName, String namespaceURI) {
- if(level == localNames.length -1) {
- return isRequired(level, localName, namespaceURI);
+ if(level < getPathLength()) {
+ if(level == localNames.length -1) {
+ return isRequired(level, localName, namespaceURI);
+ }
}
return false;
}
@@ -303,7 +316,7 @@
Iterator<PathPackage> iter = packages.iterator();
while (iter.hasNext()) {
PathPackage pack = iter.next();
- if(level < pack.getPathLength() && pack.isMatch(level, localName,
namespaceURI)) {
+ if(pack.isMatch(level, localName, namespaceURI)) {
return true;
}
}
Modified:
branches/6.1.x/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/streaming/StreamingResultsProducer.java
===================================================================
---
branches/6.1.x/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/streaming/StreamingResultsProducer.java 2009-06-09
18:11:52 UTC (rev 1032)
+++
branches/6.1.x/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/streaming/StreamingResultsProducer.java 2009-06-10
01:48:53 UTC (rev 1033)
@@ -48,7 +48,7 @@
public StreamingResultsProducer(ExecutionInfo info, XMLConnectorState state) throws
ConnectorException {
this.info = info;
- Map<String, String> namespace = info.getNamespaces();
+ Map<String, String> namespace = info.getPrefixToNamespacesMap();
XMLReader reader;
try {
reader = ReaderFactory.getXMLReader(state);
Modified:
branches/6.1.x/connectors/connector-xml/src/test/java/com/metamatrix/connector/xml/TestElementCollector.java
===================================================================
---
branches/6.1.x/connectors/connector-xml/src/test/java/com/metamatrix/connector/xml/TestElementCollector.java 2009-06-09
18:11:52 UTC (rev 1032)
+++
branches/6.1.x/connectors/connector-xml/src/test/java/com/metamatrix/connector/xml/TestElementCollector.java 2009-06-10
01:48:53 UTC (rev 1033)
@@ -70,4 +70,16 @@
fail(e.getMessage());
}
}
+
+ public void testGetRoot() {
+ String path = "/";
+ int itemCount = 1;
+ try {
+ Document doc = new DocumentImpl(new FileInputStream(filename), "foo");
+ List result = builder.getElements(doc, Arrays.asList(path));
+ assertEquals(itemCount, result.size());
+ } catch (Exception e) {
+ fail(e.getMessage());
+ }
+ }
}