![]() | InDesign SDK 20.5 |
#include <IXMLUtils.h>

Classes | |
| class | IXMLCallback |
Public Types | |
| enum | { kDefaultIID = IID_IXMLUTILS } |
| enum | CalcXMLParent_Result { kSuccessCalc = 0, kStartUnmatched = 1, kEndUnmatched = 2, kBothUnmatched = kStartUnmatched+kEndUnmatched } |
Public Member Functions | |
| virtual UIDRef | GetBackingStore (IDocument *doc)=0 |
| virtual UIDRef | GetBackingStore (IDataBase *db)=0 |
| virtual IIDXMLElement * | QueryDocElement (IDocument *document)=0 |
| virtual IIDXMLElement * | QueryDocElement (IDataBase *db)=0 |
| virtual IIDXMLElement * | QueryRootElement (IIDXMLElement *xmlDocElement)=0 |
| virtual IIDXMLElement * | QueryRootElement (IDocument *document)=0 |
| virtual IIDXMLElement * | QueryRootElement (IDataBase *db)=0 |
| virtual IXMLTagList * | QueryXMLTagList (IDataBase *db)=0 |
| virtual IXMLStyleToTagMap * | QueryXMLStyleToTagMap (IDataBase *db)=0 |
| virtual IXMLTagToStyleMap * | QueryXMLTagToStyleMap (IDataBase *db)=0 |
| virtual ITextModel * | QueryTextModel (const IIDXMLElement *element)=0 |
| virtual IXMLReferenceData * | QueryXMLReferenceData (IPMUnknown *item, bool16 allowTOP=kFalse)=0 |
| virtual IXMLReferenceData * | QueryXMLReferenceData (const UIDRef &item, bool16 allowTOP=kFalse)=0 |
| virtual IXMLReferenceData * | QueryXMLReferenceData (const UIDRef &storyUIDRef, TextIndex textIndex, bool16 allowTOP=kFalse)=0 |
| virtual IXMLReferenceData * | QueryXMLReferenceData (ITextModel *textModel, TextIndex textIndex, bool16 allowTOP=kFalse)=0 |
| virtual IXMLReferenceData * | QueryXMLReferenceData (const XMLReference &xmlReference)=0 |
| virtual bool16 | GetElementIndices (const IIDXMLElement *element, TextIndex *startPos, TextIndex *endPos)=0 |
| virtual void | GetElementMarkerPositions (IIDXMLElement *element, TextIndex *startPos, TextIndex *endPos)=0 |
| virtual bool16 | CalculateStartEndTextIndex (IIDXMLElement *element, int32 beforeChildIndex, TextIndex &startTextIndex, TextIndex &endTextIndex)=0 |
| virtual ErrorCode | UpdateAutoAttrib (const XMLReference &ref)=0 |
| virtual XMLReference | GetStoryXMLReference (const UIDRef &storyRef)=0 |
| virtual XMLReference | GetStoryThreadXMLReference (const UIDRef &storyUIDRef, TextIndex textIndex)=0 |
| virtual XMLReference | GetStoryThreadXMLReference (ITextModel *textModel, TextIndex textIndex)=0 |
| virtual int32 | CalcXMLParent (XMLReference &startParentXMLRef, int32 &startIndexInParent, K2Vector< XMLReference > &childRefList, XMLReference &endParentXMLRef, int32 &endIndexInParent, TextIndex startTextIndex, TextIndex endTextIndex, ITextModel *iTextModel, bool16 useReverseSearch=kTrue)=0 |
| virtual void | CalcXMLElementsInTextRange (ITextModel *iTextModel, TextIndex startTextIndex, TextIndex endTextIndex, XMLReference &parentXMLRef, K2Vector< XMLReference > &childRefList)=0 |
| virtual ErrorCode | AssignTagUID (const WideString &strTag, IDataBase *db, UID colorUID, UID &tagUID)=0 |
| virtual bool16 | IsTagValid (const WideString &tag)=0 |
| virtual bool16 | IsNmtoken (const PMString &token)=0 |
| virtual bool16 | IsValidXMLComment (const PMString &comment)=0 |
| virtual bool16 | IsValidXMLPITarget (const PMString &piTarget)=0 |
| virtual bool16 | IsValidXMLPIData (const PMString &piData)=0 |
| virtual bool16 | IsTaggablePageItem (IPMUnknown *item)=0 |
| virtual void | FindUnusedTags (UIDList &unusedTag)=0 |
| virtual UID | ImportHREF (IDataBase *db, const PMString &href, const IDFile *relativeTo, bool16 &useFrame, UIFlags uiFlags=kFullUI)=0 |
| virtual bool16 | IsElementLocked (const IIDXMLElement *element)=0 |
| virtual bool16 | IsStoryLocked (const UIDRef &storyRef)=0 |
| virtual bool | HasUnlockedStory (IDataBase *db)=0 |
| virtual bool16 | LinkElementInTextRange (const UIDRef &storyUIDRef, TextIndex start, int32 numChars)=0 |
| virtual UID | GetGraphicFrame (const UIDRef &contentUID)=0 |
| virtual bool16 | IsElementAGraphic (IIDXMLElement *element) const =0 |
| virtual bool16 | GetActualContent (UIDRef &contentRef)=0 |
| virtual void | ValidateXML (const XMLReference &startXMLRef, K2Vector< XMLDTDValidationError > &errors, int32 maxErrors=250, bool16 treatAsRoot=kFalse, bool16 checkHasDTD=kFalse)=0 |
| virtual ErrorCode | ExportElement (IIDXMLElement *element, bool16 includeHeader, IXMLAccess *access, IXMLHandler *exportHandler, const IDFile &sysFile, IDocument *doc, const PMString &formatName, UIFlags uiFlags) const =0 |
| virtual void | ExportDTDToStream (const XMLReference &xmlRef, IXMLOutStream *s, bool16 internalSubsetOnly=kFalse)=0 |
| virtual bool16 | IsExportableInCopyStory (const UIDRef &storyUIDRef)=0 |
| virtual bool16 | FindMissingFile (PMString filename, IDFile &fileToImport)=0 |
| virtual XMLReference | GetImportedRootXMLReference (IPMUnknown *importer)=0 |
| virtual void | ForEachElement (IIDXMLElement *root, IXMLCallback *callback)=0 |
| virtual bool16 | IsParentCellWithType (IIDXMLElement *childElement, CellType cellType)=0 |
| virtual ErrorCode | SetShouldDeleteElementOnContentDeletion (const bool16 shouldDelete=kTrue) const =0 |
| virtual bool16 | ShouldDeleteElementOnContentDeletion () const =0 |
| virtual ErrorCode | SetLayoutTag (const UIDList &itemList, const UIDRef &tag, bool16 retag, bool16 allowPresetUI)=0 |
Public Member Functions inherited from IPMUnknown | |
| virtual IPMUnknown * | QueryInterface (PMIID interfaceID) const =0 |
| virtual void | AddRef () const =0 |
| virtual void | Release () const =0 |
Utilities for traversing and working within the logical structure tree.
Enumeration containing return values for CalcXMLParent()
| pure virtual |
Create a new tag (IXMLTag) in the tag-list (IXMLTagList).
| strTag | specifies the tag-name to use |
| db | identifies the database, into whose tag-list the new tag is inserted |
| colorUID | contains the UID of the color to use for the tag (kInvalidUID if you don't care) |
| tagUID | contains the UID of the newly created tag or kInvalidUID if unsuccessful. |
| pure virtual |
Calculate the range of text before/after/in between child objects per the XML structure. Used when generating chunks of XML content.
| element | specifies XML element of interest |
| beforeChildIndex | specifies the indicies to be calculated are BEFORE this child (to get the indices after the last child pass the last child index + 1) |
| startPos | [OUT] start of text-range before specified child |
| endPos | [OUT] end of text-range before specified child |
| pure virtual |
Given a text range, calculate a list of top-level XML elements that are fully contained in the range. Elements that are partially inside the range are not included in the list. startTextIndex and endTextIndex must be in the same story thread.
[IN] text model of the range @ startTextIndex [IN] TextIndex to start the calculation @ endTextIndex [IN] TextIndex to stop the calculation (INCLUSIVE, this means range of 3,3 is actually one character; 3,2 signifies an insertion position) @ parentXMLRef [OUT] the parent of the elements in chilRefList @ childRefList [OUT] a list of top-level children in the text range
| pure virtual |
Perform the element calculations as if the given text range is to be tagged. Given a text range, determine the XML element (given as XMLReference) that should be the parent (along with the child index) of the selection. Also calculates a list of children of the final parent that should become the children of the created element
| startParentXMLRef | parent XML element to start the calculation. Receives the XML element that should be the parent of the selection. If the result is not kSuccessCalc, receives the parent of startTextIndex |
| startIndexInParent | receives the child index of startParentXMLRef the selection should be inserted as |
| childRefList | a list of children of startParentXMLRef that should become children of the new XML element. Valid on return only if returned result code is kSuccessCalc |
| endParentXMLRef | if the result is not kSuccessCalc, receives the parent of endTextIndex. Valid on return only if returned result code is not kSuccessCalc |
| endIndexInParent | if the result is not kSuccessCalc, receives the child index of endParentXMLRef. Valid on return only if returned result code is not kSuccessCalc |
| startTextIndex | TextIndex to start the calculation |
| endTextIndex | TextIndex to stop the calculation (INCLUSIVE, this means range of 3,3 is actually one character; 3,2 signifies an insertion position) |
| iTextModel | text model of text to insert |
| useReverseSearch | Usually, this method searches the child elements in the reverse order, from back to front. This is to optimize for the case of repeated append operations, such as when building XML structure during import using the parsed order to create elements. Reverse search is faster in this case because most of the desired data is at the end of the child list. Set this parameter to kFalse will cause the search to be done in the front to back order. This search order can be faster for cases such as building the structure in the reverse order, where most of the desired data is at the front of the child list |
| pure virtual |
Export the DTD to the given stream.
| xmlRef | XMLReference of any element in the XML to export the DTD from |
| s | stream to export to |
| internalSubsetOnly | whether to write internal subset only |
| pure virtual |
Export an XML element and its children to a stream
| element | specifies the element to export |
| includeHeader | Include the DTD in the XML? |
| access | used to navigate and export the sub-elements |
| exportHandler | contains the stream to write to |
| sysFile | the actual file we are writing to |
| doc | document we are writing the XML from |
Allow the user to find a missing file referenced in the XML. In the server case log an error to the error list
| filename | string that describes the file name in the XML |
| fileToImport | string that returns the file name that was selected |
| pure virtual |
Given an open document, return which are not used to mark-up content in the document.
| unusedTag | [OUT] list of tags not marking up content in document implied by its database. Note that the database of the UIDList supplied should be the database of the document containing the tags that the query is about. |
| pure virtual |
Iterate a portion of the XML tree, using the supplied element as the root of a sub-tree. Will call into the callback object for each element in the sub-tree. Uses a non-recursive algorithm so it works with deep trees.
| root | The root of the elements to iterate. |
| callback | The object to callback for each element Returns kInvalidXMLReference if no root element is found. |
| pure virtual |
Return the taggable content UIDRef that's associated with the incoming UID. Returns true if the item can be tagged. Returns a valid contentRef if there is content that can be immediately tagged. A return value of kTrue, together with an invalid contentRef shows that item can be tagged if placeholder content can be added.
If caller passed in a graphic frame, this method will return the taggable content from the graphic frame. If it is a text frame, will return the story.
If its a graphic frame, and it has content, this method will tunnel down to the children to find taggable content. If the frame has content, but the content isn't taggable, this method would flag an error by returning kFalse
| contentRef | [OUT] holds the content item if it can be found |
| pure virtual |
Get the positions of the marker characters for the given element returns kTrue if the positions are marker positions; kFalse if content position (i.e. story element which does not have markers)
| element | specifies element of interest |
| startPos | [OUT] TextIndex where the begin-element marker tag is located in the textflow |
| endPos | [OUT] TextIndex where the end-element marker tag is located in the textflow |
| pure virtual |
Get the actual positions of the marker characters for the given element. The values returned are always marker positions in the story that contains the markers, which is not always the content's story (such as link elements)
| element | specifies XML element of interest |
| startPos | [OUT] start of text-range tagged by this element |
| endPos | [OUT] end of text-range tagged by this element |
Returns the graphic frame that contains the content. If the content is a text model, it returns the graphic frame that contains the multi-column frame. If the content is a page item, it returns the graphic frame that contains the page item.
| contentUID | specifies the content item that we're interested in |
| pure virtual |
Returns the the root element of the imported XML data.
| importer | An interface on kXMLImporterBoss. Must not be nil. |
| pure virtual |
Returns the XMLReference corresponding to the given text position's story thread
| storyUIDRef | UIDRef of the story |
| textIndex | TextIndex of the text position |
| pure virtual |
Returns the XMLReference corresponding to the given text position's story thread
| textModel | TextModel of the story |
| textIndex | TextIndex of the text position |
| pure virtual |
Return the XMLReference that corresponds to the story. In the case the story is the backing store (unplaced content), the XML document's XMLReference is returned
| storyRef | specifies the story of interest |
| pure virtual |
Returns true if the database contains unlocked stories
| in | IDatabase current database |
| pure virtual |
Import a page item into the given database using the 'href' passed in as the path to the file. Note that this doesn't imply that the content will be loaded across the wire; it is strictly a path in the local file system at the time of writing.
| db | database to import the page item into |
| href | a string which represents the path to the file you want to import |
| relativeTo | if passed in (it can be nil), the href passed in will be used as a relative path with respect to 'relativeTo' if 'relativeTo' is a directory, the path will stem from it, if 'relativeTo' is a file, the path will stem from it's parent directory |
| useFrame | [OUT] parameter |
| uiFlags | specifies how much UI to show |
| pure virtual |
Determine if we consider the element to be a graphic element. If it has an href and no content or children, then we consider it a graphic
| element | specifies element of interest |
| pure virtual |
Checks to see if the content is locked given the element via ITextLockData on given element.
| element | specifies element of interest |
| pure virtual |
determine whether the given story is exportable as an InCopy story from XML's perspective
| storyUIDRef | UIDRef of story to export |
| pure virtual |
Determine whether the given token matched XML 1.0 specification's (REC-xml-20001060) production for [7] Nmtoken
| token | token to check |
| pure virtual |
Checks whether the Parent of the Passed element is Table-Cell With CellType being equal to the passed CellType like kPageItemContentType, kTextContentType etc
| childElement | The element whose Parent we need to check, if parent is not Table-Cell then returns kFalse |
| cellType | The cellType of the Parent of element which is Table-Cell is also matched if the Parent is Table-Cell. Returns kTrue if Parent is Table-Cell and CellType also matches the passed cellType. |
| pure virtual |
Checks to see if the content is locked given the story
NOTE: now it works for generic page items too, not just stories
| storyRef | specifies story of interest |
| pure virtual |
Determine if given boss object could be marked-up. If this item or a child down the hierarchy has an IXMLReferenceData IFace, it is it can be marked-up (is taggable). Alternatively if this item is a graphic frame, it can be marked-up (is taggable). If this item is a group or a guide it cannot be marked-up (is not taggable)
| item | interface on boss object (page item) of interest |
| pure virtual |
Checks to see if a given tag-name would be appropriate as the name for an XML element (not whether tag already exists as that would imply a database). Determines in order;
For instance, names for an XML element can only begin with an alphabetic character or an underline, or a colon.
| tag | name of tag to check |
| pure virtual |
Determine whether the given comment is a valid XML comment per XML 1.0 specification (REC-xml-20001006), section 2.5
| comment | comment to check |
| pure virtual |
Determine whether the given string is a valid XML processing instruction data per XML 1.0 specification (REC-xml-20001006), section 2.6
| piData | PI data to check |
| pure virtual |
Determine whether the given string is a valid XML processing instruction target per XML 1.0 specification (REC-xml-20001006), section 2.6
| piTarget | PI target to check |
| pure virtual |
Determines whether there are any link elements in the given text range.
| storyUIDRef | specifies story of interest |
| start | where to start looking for link elements |
| numChars | how many chars forward in the textmodel to search |
| pure virtual |
Return the XML document element for the given document
| document | specifies document of interest |
| pure virtual |
Return the XML document element for the given database, based on the database' document
| db | specifies database of interest |
| pure virtual |
Return the root element of the given XML document element
| xmlDocElement | XML document element of interest |
| pure virtual |
Return the root element of the given document
| document | specifies document of interest |
| pure virtual |
Return the root element of the given database (based on the db's document)
| db | database from document |
| pure virtual |
Query for the text model associated with given element.
| element | specifies element of interest. Note that element->GetContentItem() should be a valid UID. |
| pure virtual |
Given any interface on an arbitrary boss object, determine if there is XML data associated with it's content. This method checks the contents of frames in the following order;
It will try to return an IXMLReferenceData given knowledge about the model format.
| item | specifies the boss object of interest (frame of some kind) |
| allowTOP | set to be kTrue if text on path frames are allowable, kFalse otherwise |
| pure virtual |
Overload of method QueryXMLReferenceData, given a persistent reference rather than an interface ptr.
| item | specifies frame of interest |
| allowTOP | kTrue if text on path frames are allowable, kFalse otherwise |
| pure virtual |
Given a text index position, return the IXMLReferenceData associated with the text index.
| storyUIDRef | UIDRef of the story the text index is in |
| textIndex | TextIndex to query IXMLReferenceData for |
| allowTOP | kTrue if text on path frames are allowable, kFalse otherwise |
| pure virtual |
Given a text index position, return the IXMLReferenceData associated with the text index.
| textModel | TextModel of the story the text index is in |
| textIndex | TextIndex to query IXMLReferenceData for |
| allowTOP | kTrue if text on path frames are allowable, kFalse otherwise |
| pure virtual |
Given a XMLReference, return the IXMLReferenceData associated with the element's content, if applicable
| xmlReference | XMLReference of the element to process |
| pure virtual |
Query for the mapping between paragraph/character styles and tags in the given databse.
| db | specifies database of interest |
| pure virtual |
Query for the tag-list in the given database.
| db | database containing tag-list of interest |
| pure virtual |
Query for the mapping between tag-names and paragraph/character styles in the given database.
| db | database containing mapping of interest |
| pure virtual |
Set the tag for a layout item (page item)
| target | - The target to use when tagging the object |
| tag | - The UIDRef of the tag you want to use |
| retag | - Whether to retag an existing element with a new tag |
| allowPresetUI | - Allow the tagging preset UI to popup |
| pure virtual |
Sets the preference to also delete the XML element when its content has been deleted. Default is kFalse.
| pure virtual |
Gets the value for preference to also delete the XML element when its content has been deleted.
| pure virtual |
Automatic attributes are at present 'href'. If the element associated with the given XMLReference is a graphic item, then at the time of writing (InDesign 2.0) it will automatically get an href attribute added to it.
| ref |
| pure virtual |
Validate the XML against a DTD.
| startXMLRef | XMLReference of the element to start the validation at. Use the document element to validate the entire XML |
| errors | [OUT] receives vector of validation errors found |
| maxErrors | maximum number of errors to retrieve. Use -1 to get all the errors |
| treatAsRoot | if startXMLRef is not the document element or the root element, whether to check startXMLRef against DOCTYPE root element type. This is used when validating from something other than the root, but still wants to treat the starting element as root |
| checkHasDTD | if startXMLRef has no DTD reference, whether it should be flagged as an error. Set this flag to kFalse, and XML without DTD will also "pass" the validation |