You are viewing a plain text version of this content. The canonical link for it is here.
Posted to xindice-users@xml.apache.org by Gareth Boden <be...@albatross.snowplains.org> on 2002/03/25 18:11:33 UTC
Help with querying and namespaces needed!
Hi,
I'm having big problems trying to pull document fragments from queries
into another document using the XMLDB and DOM APIs.
I have no declared namespaces in any of my documents. So I am querying a
collection which contains documents which look like:
<MyDocument>
Foo Bar Wibble
</MyDocument>
I'm using the XPathService.query() method with query "/MyDocument" to
retrieve all documents from my collection.
For each document, I'm trying to add the query result to another document.
final Node mydocs = document.createElement("MyDocuments);
and then for each result in my query,
Node n =
document.importNode(resource.getContentAsDOM().getFirstChild(),
true);
mydocs.appendChild(n);
But the importNode gives me:
org.w3c.dom.DOMException: DOM003 Namespace error
at org.apache.xerces.dom.AttrNSImpl.<init>(AttrNSImpl.java:125)
at
org.apache.xerces.dom.CoreDocumentImpl.createAttributeNS(CoreDocument
Impl.java:1402)
at
org.apache.xerces.dom.CoreDocumentImpl.importNode(CoreDocumentImpl.ja
va:993)
at
org.apache.xerces.dom.CoreDocumentImpl.importNode(CoreDocumentImpl.ja
va:957)
at
org.apache.xerces.dom.CoreDocumentImpl.importNode(CoreDocumentImpl.ja
va:903)
Any clues? I've tried adding:
service.setNamespace("src",
"http://xml.apache.org/xindice/Query");
service.setNamespace("xmlns",
"http://www.w3.org/2000/xmlns/");
to my XPathQueryService, but to no avail.
Gareth