• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

How to Detect "Phantom XML" Items in InDesign's XML Structure

Valorous Hero ,
Oct 08, 2024 Oct 08, 2024

Copy link to clipboard

Copied

Hello!
There is an issue I am experiencing where when a page is deleted that used to have structure somehow has one piece of the structure thinking there's still a document element attached to it.

Does anyone have advice on how to detect these items? I think maybe they all have "XMLStory" as the page-element parent at the top of it all, just thinking.

SillyV_0-1728390322576.png

I would like to create a method that can be fed an XML element, and it needs to find its XML parents all the way to the top, and return true if the parent of the xmlContent is an instance of XMLStory.
Apparently the ones which do not have a representation in the pages are called "XMLStory", which under it has some kind of all valid elements even if they are not on the document pages.
I found some issue which may be a bug, where indeed I was getting a false positive with the parentTextFrame technique for one item and sure enough, when I visited it in the XML Structure panel, it had a "Go to Item" menu option available.
However, clicking this option just made InDesign unresponsive for a second, before in the XML Structure it underlined the nodes (this is what it does when it 'selects' an item on the page normally related to an XML node), but nothing effectively happens in the document.
So the problem as I would like to call it is "phantom XML".

 

I wish to ignore all these non-existing-item XML nodes, does anyone have an idea on how to accomplish this?

 

 

<Title renamed by MOD>

 

TOPICS
Scripting

Views

457

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 2 Correct answers

Community Expert , Oct 08, 2024 Oct 08, 2024
quote

Hi @Silly-V!

> "Does anyone have advice on how to detect these [phantom XML] items?"

Did you get an answer to this? eg. Is there a function to detect a phantom?

- Mark


By @m1b

 

Easy. 

 

In case of the XMLStory - check if it has any textContainers.

 

In case of other objects - if they have parentPage. 

 

Votes

Translate

Translate
Valorous Hero , Oct 11, 2024 Oct 11, 2024

In my case and anything I foresee in the future for it, I saw how the items that are not associated with an 'on-page' item can have a parent of XmlStory, and although I have not used parentPage as of yet, I was able to eliminate going down the branch that had the 'phantom' items by sensing if the xmlContent's parent was an XmlStory. I noticed that the Root was parented by XmlStory, so I made my collection method to ignore items which such a parent type of their xmlContent when it's one-level dow

...

Votes

Translate

Translate
Community Expert ,
Oct 08, 2024 Oct 08, 2024

Copy link to clipboard

Copied

Can you share your INDD document?

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Oct 08, 2024 Oct 08, 2024

Copy link to clipboard

Copied

Yes, the file is attached here.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 08, 2024 Oct 08, 2024

Copy link to clipboard

Copied

This is a preview of your XML as a flat database:

RobertatIDTasker_0-1728398510571.png

Unfortunately, even after IDMLing - InDesign crashes when trying to access those elements - double click on any cell in my tool.

 

This is a Text structure of your document:

RobertatIDTasker_2-1728399078483.png

I've double clicked on the last row on the list - it's your phantom Story.

When I switch to InDesign - blinking cursor is in the center - marked with a red Rectangle.

 

This is Objects structure of your document:

RobertatIDTasker_3-1728399099017.png

 

What is strange - when I double click onn the Story in the XML structure and then load info about Selection - this is what I get - but those objects are fantoms as well:

RobertatIDTasker_4-1728399391906.png

 

 

After deleting manually this phantom Story - this is a new XML structure:

RobertatIDTasker_5-1728399705169.png

 

Object Structure is pretty much the same:

RobertatIDTasker_6-1728399766266.png

 

And the Text structure - no more phantom Story at the end:

RobertatIDTasker_7-1728399857941.png

 

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 08, 2024 Oct 08, 2024

Copy link to clipboard

Copied

But that's what I get when I drag it back:

RobertatIDTasker_8-1728400004887.png

 

When you delete objects on the Page - InDesign doesn't remove them from the XML structure - still keeps them "inside".

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 08, 2024 Oct 08, 2024

Copy link to clipboard

Copied

And they are no longer phantoms.

 

Objects structure:

RobertatIDTasker_0-1728400246937.png

 

Text structure:

RobertatIDTasker_1-1728400318100.png

 

And fully clickable XML structure:

RobertatIDTasker_2-1728400420928.png

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Oct 08, 2024 Oct 08, 2024

Copy link to clipboard

Copied

So it just sounds like the non-associated XML should just be removed, yea?
Thank you for the detailed investigation and insights!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 08, 2024 Oct 08, 2024

Copy link to clipboard

Copied

quote

So it just sounds like the non-associated XML should just be removed, yea?


By @Silly-V

 

Yes, exactly. What you see on the page - is a graphical representation of the XML's contents.

 

When you delete associated object on the Page - you are deleting only it's "container" - but it is still present in the XML structure. 

 

It's not the same as deleting TextFrame of a Story with a single TextFrame.

 

quote

Thank you for the detailed investigation and insights!


By @Silly-V

 

You are welcome.

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 08, 2024 Oct 08, 2024

Copy link to clipboard

Copied

Hi @Silly-V!

> "Does anyone have advice on how to detect these [phantom XML] items?"

Did you get an answer to this? eg. Is there a function to detect a phantom?

- Mark

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 08, 2024 Oct 08, 2024

Copy link to clipboard

Copied

quote

Hi @Silly-V!

> "Does anyone have advice on how to detect these [phantom XML] items?"

Did you get an answer to this? eg. Is there a function to detect a phantom?

- Mark


By @m1b

 

Easy. 

 

In case of the XMLStory - check if it has any textContainers.

 

In case of other objects - if they have parentPage. 

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 08, 2024 Oct 08, 2024

Copy link to clipboard

Copied

Or simply if it's XMLStory: 

 

XmlStory

XML text content that has not yet been placed in the layout.

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 11, 2024 Oct 11, 2024

Copy link to clipboard

Copied

LATEST

Great! Thanks Robert.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Oct 11, 2024 Oct 11, 2024

Copy link to clipboard

Copied

In my case and anything I foresee in the future for it, I saw how the items that are not associated with an 'on-page' item can have a parent of XmlStory, and although I have not used parentPage as of yet, I was able to eliminate going down the branch that had the 'phantom' items by sensing if the xmlContent's parent was an XmlStory. I noticed that the Root was parented by XmlStory, so I made my collection method to ignore items which such a parent type of their xmlContent when it's one-level down.
Maybe this isn't quite correct, but for me just in the cases where I delete a page - it works.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines