|
I ran into a problem retrieving an object that I have
saved in the Xindice database. I have used JaxMe to create and object and store
the xml as a resource by using SAX. It works fine, and the XML stored contains
all the data.
Unfortunately it saves my xml namespace as part of
the xml, so I have to use namespaces to retrieve it.
1) First of all I am unsure to what extent Xindice
supports namespaces, it does, right ?
2) Then I wonder if I am using getContentAsSAX in the
right way
I have verified that the following function returns
the right data,
public
ResourceSet getDeployedAccounts() throws XMLDBException { String xpath =
"//data:DeployedAccount"; XPathQueryService service = (XPathQueryService)
baseCollection.getService("XPathQueryService", "1.0"); service.setNamespace("data",http://commons.dspc.net/accountmodel); return
service.query(xpath) }
It is in the following code I get an
exception,
List list = new ArrayList(); Unmarshaller unmarshal = accountModelContext.createUnmarshaller(); UnmarshallerHandler
handler = unmarshal.getUnmarshallerHandler(); ResourceSet resultSet = getDeployedAccounts(); ResourceIterator results = resultSet.getIterator(); while (results.hasMoreResources()) {
XMLResource res =
(XMLResource)results.nextResource(); res.getContentAsSAX(handler);
DeployedAccount tp = (DeployedAccount)
handler.getResult(); tp.setDbKey(res.getId()); list.add(tp); } return list;
Caused by: org.xml.sax.SAXParseException: Unknown
attribute: in namespace
[junit] at
org.apache.ws.jaxme.impl.JMHandlerImpl.addAttribute(JMHandlerImpl.java:81) [junit] at
net.dspc.commons.accountmodel.impl.DeployedAccountTypeHandler.addAttribute(Unknown
Source) [junit] at
net.dspc.commons.accountmodel.impl.DeployedAccountTypeHandler.startElement(Unknown
Source) [junit] at
org.apache.ws.jaxme.impl.JMUnmarshallerHandlerImpl.startElement(JMUnmarshallerHandlerImpl.java:162) [junit] at
org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown
Source)
The XML being read is the following
:
<DeployedAccount xmlns="http://commons.dspc.net/accountmodel"
xmlns:src=""
src:col="/db/namespace.test.dspc.net"
src:key="05ffa7c060e01bd8000000f89374859c"><account-name>henrik</account-name><customer-no>123456</customer-no><home-hostname>localhost</home-hostname><home-portno>8080</home-portno><deployed-name>henrik_1234</deployed-name></DeployedAccount>
|