InDesign SDK  20.5
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
SnpImportExportXML Class Reference

Public Member Functions

ErrorCode ExportViaServiceProvider (const UIDRef &documentUIDRef, const IDFile &targetFile)
 
ErrorCode ExportElement (const XMLReference &xmlRef, const IDFile &targetFile, const PMString &formatName="XML", UIFlags uiFlags=kSuppressUI)
 
ErrorCode ExportTable (const UIDRef &tableModelUIDRef, const IDFile &targetFile)
 
ErrorCode ExportElementsAsSnippet (const IDFile &targetFile, const K2Vector< XMLReference > &elements)
 
ErrorCode Import (const UIDRef &documentUIDRef, const IDFile &targetFile, const XMLReference &xmlReferenceWhere)
 
ErrorCode ImportXMLSnippetIntoRoot (const UIDRef &documentUIDRef, const IDFile &targetFile)
 

Detailed Description

  • How to export XML using service provider
  • How to export directly from an individual element
  • How to export XML elements as a Snippet
  • How to import an XML file
  • How to import an XML snippet.

Exercising

ExportViaServiceProvider

  1. Create a new document
  2. Run the snippet ImportExportXML
  3. Choose the option ExportViaServiceProvider.
  4. If all is well, there should be no asserts (if in debug build).
  5. You should see a message about a file being created.
  6. Save snippet runner log, grab the path to the file and open the file on your local system and inspect with XML-aware editor or text editor.

    ExportElement

  1. Create a new document
  2. Run the snippet ImportExportXML
  3. Choose the option ExportElement
  4. If all is well, there should be no asserts (if in debug build).
  5. You should see a message about a file being created.
  6. Save snippet runner log, grab the path to the file and open the file on your local system and inspect with XML-aware editor or text editor.

    ExportTable

  1. Create a new document
  2. Run the snippet ImportExportXML
  3. Choose the option ExportTable
  4. If all is well, there should be no asserts (if in debug build).

    ExportElementsAsSnippet

  1. Create a new document
  2. Run the snippet ImportExportXML
  3. Choose the option ExportElementsAsSnippet
  4. If all is well, there should be no asserts (if in debug build).
  5. You should see a message about a file being created.
  6. Save snippet runner log, grab the path to the file and open the file on your local system and inspect with XML-aware editor or text editor.

    Import

  1. Make sure you have already run ExportViaServiceProvider
  2. Create a new document
  3. Run the snippet ImportExportXML
  4. Choose the option Import
  5. If all is well, there should be no asserts (if in debug build).
  6. You should see new XML elements in the logical structure

    ImportXMLSnippetIntoRoot

  1. Make sure you have already run ExportElementsAsSnippet option
  2. Run the snippet ImportExportXML
  3. Create a new document
  4. Choose the option ImportXMLSnippetIntoRoot
  5. If all is well, there should be no asserts (if in debug build).
  6. You should see the content that was created on ExportElementsAsSnippet now imported at the root of the document
  7. Note that there will be document content as well as XML elements
See Also
_SnpRunnerImportExportXML::Run for driver code

Member Function Documentation

ErrorCode SnpImportExportXML::ExportElement (const XMLReferencexmlRef,
const IDFiletargetFile,
const PMStringformatName = "XML",
UIFlags uiFlags = kSuppressUI 
)

Export only the supplied element to specified file as XML.

Precondition
xmlRef should allow IIDXMLElement to be instantiated
Parameters
xmlRefreference to element (IIDXMLElement) to export
targetFilefile to which output should be written
Returns
ErrorCode kSuccess on success, some other ErrorCode otherwise
ErrorCode SnpImportExportXML::ExportElementsAsSnippet (const IDFiletargetFile,
const K2Vector< XMLReference > & elements 
)

Export the XML elements supplied as Snippet

Parameters
targetFilespecifies the file to write to
elementslist of elements (IIDXMLElement) to export as Snippet
Returns
ErrorCode kSuccess on success, some other ErrorCode otherwise
ErrorCode SnpImportExportXML::ExportTable (const UIDReftableModelUIDRef,
const IDFiletargetFile 
)

Export a tagged table to specified file

Precondition
tableModelUIDRef should allow ITableModel to be instantiated
table should be tagged, i.e. IXMLReferenceData should return XMLReference of element (IIDXMLElement) that can be instantiated
Parameters
tableModelUIDRefidentifies table to export to specified file
targetFilefile to which output should be written
Returns
ErrorCode kSuccess on success, some other ErrorCode otherwise
ErrorCode SnpImportExportXML::ExportViaServiceProvider (const UIDRefdocumentUIDRef,
const IDFiletargetFile 
)

Export the logical structure of the given document to specified file as XML.

Precondition
documentUIDRef should allow IDocument to be instantiated
Parameters
documentUIDRefdocument of interest
targetFilefile to which output should be written
Returns
ErrorCode kSuccess on success, some other ErrorCode otherwise
ErrorCode SnpImportExportXML::Import (const UIDRefdocumentUIDRef,
const IDFiletargetFile,
const XMLReferencexmlReferenceWhere 
)

Import an XML file into the document

Precondition
documentUIDRef should allow IDocument to be instantiated
Parameters
documentUIDRefspecifies document into which to import
targetFileXML data file to import
xmlReferenceWherekInvalidXMLReference to import into the root, since this can legitimately be kInvalidXMLReference, we require documentUIDRef
Returns
ErrorCode kSuccess on success, some other ErrorCode otherwise
ErrorCode SnpImportExportXML::ImportXMLSnippetIntoRoot (const UIDRefdocumentUIDRef,
const IDFiletargetFile 
)

Import a set of XML elements from a Snippet file, which should be set up by ExportElementsAsSnippet.

Precondition
documentUIDRef should allow IDocument to be instantiated
Parameters
documentUIDRefdocument into which
targetFilespecifies the Snippet file to import
Returns
ErrorCode kSuccess on success, some other ErrorCode otherwise