Article View: adobe.indesign.sdk
Article #559importing xml from a stream instead of file
From: B_Pinsard
Date: Wed, 31 Dec 2008 11:41
Date: Wed, 31 Dec 2008 11:41
74 lines
3927 bytes
3927 bytes
Hello
I am facing to a problem.
I'm trying to import directly xml in a document from a stream because my plugin have connection to a alternative data source and I would prefer not having to write to temp file for optimization.
I tried this code:
_____________________________________________________________________
//instanciate a xmlimporter boss
InterfacePtr<IXMLImporter> importer((IXMLImporter*)::CreateObject(kXMLImporterBoss, IID_IXMLIMPORTER));
ASSERT(importer);
if(!importer) {
break;
}
//get the importData
InterfacePtr<IImportXMLData> importerXMLData(importer, IID_IPMUNKNOWNDATA);
ASSERT(importerXMLData);
if(!importerXMLData) {
break;
}
//set the doc database and the xmlRef where to import
//with database and xmlRef as valid object from the same document.
importerXMLData->Set(database, IDFile(), xmlRef, kSuppressUI);
//instantiate a ISAXEntititySolver fo DoImport call
InterfacePtr<ISAXEntityResolver> saxentrslvr(CreateObject2<ISAXEntityResolver>(kXMLEntityResolverBoss));
ASSERT(saxentrslvr);
if(!saxentrslvr) {
break;
}
//giving the stream holding xml
importer->DoImport(stream,saxentrslvr);
_____________________________________________________________________
I am not yet at ease with the ID object model, and I do not know if it's right but the program crash with the following.
_____________________________________________________________________
~InstanceList(): 9 outstanding references to UID 1 (Class kDocBoss).
~InstanceList(): 1 outstanding references to UID 2 (Class kRIDXBoss).
~InstanceList(): 1 outstanding references to UID 5 (Class kContentMgrBoss).
~InstanceList(): 12 outstanding references to UID 6 (Class WorkspacePrefix + 2 (0x2202)).
~InstanceList(): 1 outstanding references to UID 106 (Class kStyleGroupHierarchyBoss).
~InstanceList(): UID 122 (Class kGraphicStateBoss) did not get flushed from the instance cache.
~InstanceList(): 1 outstanding references to UID 129 (Class kRootObjectStyleHierarchyBoss).
~InstanceList(): UID 130 (Class kObjectStyleBoss) did not get flushed from the instance cache.
~InstanceList(): UID 168 (Class kDocumentLayerBoss) did not get flushed from the instance cache.
~InstanceList(): UID 169 (Class kDocumentLayerBoss) did not get flushed from the instance cache.
~InstanceList(): 1 outstanding references to UID 186 (Class kAssignmentBoss).
~InstanceList(): UID 264 (Class kDataLinkBoss) did not get flushed from the instance cache.
~InstanceList(): UID 356 (Class kDataLinkBoss) did not get flushed from the instance cache.
Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_INVALID_ADDRESS at address: 0x55555555
0x394612c6 in operator delete ()
________________________________________________________________________
The message differs from an execution to another.
If I remove the DoImport call, similar problems occurs when leaving the code block (due to release calls).
If you have any idea of what I'm doing wrong, I would be greatful.
Maybe that is not a good idea to do it that way.
Is it better to do a different implementation of IDataLink (holding the xml stream) and another implementation of IXMLAcquirerFilter which would return the xml stream hold by the datalink?
That process seems a bit heavy to my eyes, so I would rather the first.
Thanks.
B.Pinsard
Technical Details
Message-ID:
<59b7654e.-1@webcrossing.la2eafNXanI>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news2.google.com!newshub.sdsu.edu!webcrossingShow Full Headers
Complete Article Headers
X-Google-Thread: f63e9,d1ca49ad7b733acf,start X-Google-Attributes: gidf63e9,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit From: B_Pinsard@adobeforums.com Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news2.google.com!newshub.sdsu.edu!webcrossing Newsgroups: adobe.indesign.sdk Subject: importing xml from a stream instead of file Message-ID: <59b7654e.-1@webcrossing.la2eafNXanI> Date: Wed, 31 Dec 2008 03:41:03 -0800 Lines: 95 MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit