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

How get the untagged contents using JS?

Guest
Jul 17, 2010 Jul 17, 2010

Copy link to clipboard

Copied

Hi All,

Pl. give me the hint to get the untagged contents using JS?

Thanks in advance.

Praveen

TOPICS
Scripting

Views

1.7K

Likes

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
Participant ,
Jun 06, 2012 Jun 06, 2012

Copy link to clipboard

Copied

Hi Praveen,

                   

                    Did you complete this? If yes pls give me the points...

                        Thanks in advance...

Likes

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 ,
Jun 06, 2012 Jun 06, 2012

Copy link to clipboard

Copied

Hi,

untagged content has null associatedXMLElement. Once that said, loop through all the contents and check the associatedXMLElement value.

Loic

http://www.loicaigon.com

Likes

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
Participant ,
Jun 06, 2012 Jun 06, 2012

Copy link to clipboard

Copied

The untagged content has not null associatedXMLElement because its getting root XMLElement in such case....so how to find untagged content?

Likes

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 ,
Jun 06, 2012 Jun 06, 2012

Copy link to clipboard

Copied

Hi,

I am surprised you get that result. If an item isn't tagged, there is no way you get returned the root xml element.

Given some content of an untagged text frame :

app.selection[0].associatedXMLElements //undefined

Unless teh content makes part of some tagged textframe, which may return the associatedXMLElements of the parent and even then, no content can be associated with the root as every tagged contents are children of the root. Do you have screenshot ?

Loic

Likes

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
Participant ,
Jun 07, 2012 Jun 07, 2012

Copy link to clipboard

Copied

Mid.JPG

     The above fig represents, the selected text has placed in the middle of the "sec" tag content. so its associated element is "sec" only.

End.JPG

     This fig, selected text has placed in an end of the document. so its associated element is root tag "book".

So how can I find the untagged content through InDesign javascript?

Likes

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
LEGEND ,
Jun 08, 2012 Jun 08, 2012

Copy link to clipboard

Copied

I see from that image where Loic's confusion comes from.

That paragraph you marked is not really "untagged". If you look in the Tags panel or XML Structure pane, you will see it *is* tagged, with whatever the root object is from the tags above and below this line.

In your first example, the tagged path is "body/sec", according to the Structure pane. But what do you mean this?

... so its associated element is "sec" only.

I mean, it's clear that the paragraph in itself does not have a tag. But attempting to check if an entire paragraph is not tagged seems to be a bit tricky -- I just tried with the following script (and some variations), and got mixed results.

s = app.selection[0].parentStory;

for (pp=0; pp<s.paragraphs.length; pp++)
{
p = s.paragraphs[pp];
if (p.associatedXMLElements && p.associatedXMLElements[0].parent)
{
  if (!confirm (p.contents+"\r=>"+p.associatedXMLElements[0].parent.markupTag.name)) exit();
}
}

Likes

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
Contributor ,
Aug 23, 2022 Aug 23, 2022

Copy link to clipboard

Copied

LATEST

Hi Cenchen,

You received a response to the above question (one paragraph is missing to tag with in the xml structure)?

Likes

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