-
1. Re: How get the untagged contents using JS?
Cenchen Jun 6, 2012 4:21 AM (in response to Praveen10)Hi Praveen,
Did you complete this? If yes pls give me the points...
Thanks in advance...
-
2. Re: How get the untagged contents using JS?
Loic_aigon Jun 6, 2012 5:39 AM (in response to Praveen10)Hi,
untagged content has null associatedXMLElement. Once that said, loop through all the contents and check the associatedXMLElement value.
Loic
-
3. Re: How get the untagged contents using JS?
Cenchen Jun 6, 2012 9:51 PM (in response to Loic_aigon)The untagged content has not null associatedXMLElement because its getting root XMLElement in such case....so how to find untagged content?
-
4. Re: How get the untagged contents using JS?
Loic_aigon Jun 6, 2012 11:44 PM (in response to Cenchen)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
-
5. Re: How get the untagged contents using JS?
Cenchen Jun 7, 2012 11:32 PM (in response to Loic_aigon)The above fig represents, the selected text has placed in the middle of the "sec" tag content. so its associated element is "sec" only.
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?
-
6. Re: How get the untagged contents using JS?
[Jongware] Jun 8, 2012 1:58 AM (in response to Cenchen)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(); } }


