Hi,
Is it possible to get a reference to the containing container of an XmlDocument object? In my case, I want to accept an XQuery that is assumed to return one or more XmlDocument objects, and delete them using XmlContainer::deleteDocument(), but it doesn't seem possible because XmlDocument provides no way to gain a reference back to its container or its container's name as a string.
I know that DB XML internally knows the XmlDocument's container because calling XmlContainer::deleteDocument() on a container that does not contain the document argument will throw an exception whose message has the actual container's name embedded in it.
Right now I'm attempting to delete the document from a dummy container and then scraping this exception message to find out the real container and open it, then call deleteDocument again. This is very unreliable, however, because there is no escaping of the container's name (it could contain any of the same characters as the rest of the message).
It is not possible for me to interpret the XQuery to determine which container was used in the query without interacting with the low-level internals of XQuilla and DB XML, because these queries can be very complex and may, for example, rely on dynamically generated container names. It is not feasible to iterate over all containers attempting to delete the document from each one because containers according to DB XML can be located at any arbitrary filepath, which is not known until the time they are opened (and even if possible iterating over all containers for each returned document would be very slow).
My only other idea is to implement a custom XmlResolver (which I've been trying to avoid due to the limitation on indexing), where I cache all containers that were resolved during the query and then attempt to delete each document from each one. I may be able to bypass the indexing limitation by creating a temporary XmlManager just for the purpose, and only register my custom XmlResolver on that manager, and leave the other XmlManagers with the default resolver (if this is possible), but this seems like a complicated solution for something as simple as finding out a document's container
Am I missing something? Is there an XmlDocument method that does this? And if not, why not? Is it possible to delete an XmlDocument without a reference to its container at all?
I realize that not all XmlDocument object have a corresponding container (e.g. XmlManager::createDocument()), but I think it would be acceptable to return an empty string, null XmlContainer (if there is such a thing), or throw an exception from a call requesting the XmlDocument's container when it doesn't have one.
Any ideas for solving this problem are appreciated!