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

Untag specific table cells

Community Beginner ,
Oct 18, 2016 Oct 18, 2016

I've tagged several tables in InDesign to export them to XML. I'd like to untag the top row of cells (circled in red, currently tagged as "header"), while retaining all the interior cells (currently tagged as "Cell"). I want this because when I re-import the XML, the text wrapping in the header cells disappears.

Is there a way to untag *just* the Header cells, while leaving the Table and the Cell tags in place? When I try to untag them manually, it untags the whole table. I'd like to do it manually but I'm told I probably need a script to do it. I am thinking something along the lines of:

function mySnippet(){

  var myDocument = app.activeDocument;

  var root = app.activeDocument.xmlElements[0];

     var pages = root.evaluateXPathExpression('//Page');

     for (i=0; i<pages.length; i++)

     {

        header = i.evaluateXPathExpression('Page/Table/Header');

        // if the tag is 'header' and not cell:

        header.untag();

      }

}

But I'm very new to JavaScript so I don't know what I'm doing at all when it comes to this stuff.

TOPICS
Scripting
1.0K
Translate
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
Enthusiast ,
Oct 19, 2016 Oct 19, 2016

Hi,

I am trying to get a grip on exactly what your problem is, so forgive me.

You should be able to untag XML elements from 2 locations:

1. Structure Pane: (Open Structure Pane from View menu > Structure > Show Structure):

    Select the item you want to untag

    From the Structure Pane contextual menu (the small list menu in its upper right corner)  select Untag Element

2. From the document Tag Panel (Open Tag Panel from Windoe menu > Utilities > Tags

   Select the tag you want to delete from the tag list

   From the tag panel contextual menu (the small list menu in its upper right corner) select Delete Tag

Of course, when you untag a page item or delete its tag, the page item no longer is exported with the XML.

I will recreate your table and XML to try to see exactly what your problem is.

Shirley Hopkins

Translate
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 Beginner ,
Oct 21, 2016 Oct 21, 2016

Hi,

Sorry for the unclear explanation. It's a little hard to explain.

So as you can see from the screenshot in my previous post, I have already opened the Structure Pane as you suggested. The entire table is tagged as "Table" and is circled in this image.

Within the table, the cells in the first row are tagged as 'Header'. They are circled in the image below.

The rest of the cells are tagged as 'Cell', and are circled in the image below (the rest of the table and cells are not shown).

I want to tag just the cells in the third image. I don't want to tag the header cells. I don't want to delete them, or tag them as something else-- I want the header cells to not exist in the XML. I just want to keep the cells that are currently tagged as "cells".

But when I right-click on all the "Header" tags (and not the "cell" tags") and click "Untag Element":

the Header ​and​ the Cell elements disappear:

The same thing happens when I try to delete the tag through the Tags menu.

@Daniel Sterchi Your script does the same thing: it deletes the "Cell" elements along with the "Header" elements.

I hope this explanation makes more sense, please let me know if I should explain more!

Translate
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
People's Champ ,
Oct 21, 2016 Oct 21, 2016

That's because you can't have tagged and untagged contents inside a table. When you untag a Table cell element, you remove all teh table tags.

Translate
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 Beginner ,
Oct 25, 2016 Oct 25, 2016

Ok, so if I understand correctly, you are saying that I can't untag any element within a table, because it untags all the elements within that table, and there is no way around that?

I'm surprised. That seems...weird, and unnecessary. I thought there would be a way to tag just a few elements within a table.

Are there any workarounds to this? I don't want to tag the header cells because when I export the tagged table to XML, and then re-import it, I lose all of the formatting in the cells, including the text wrapping. For example, a cell that says:

Property Damage

Only

becomes

Property Damage Only.

And then I have to manually fix all the cells.

Translate
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
Enthusiast ,
Oct 20, 2016 Oct 20, 2016

Hi aliceell

What about this few lines

var myDoc = app.activeDocument;

var headers = myDoc.xmlElements[0].evaluateXpathExpression("Page/Table/Table/Header");

// start from the last Element

for (var i =  headers.length -1; i >= 0; i--) {

    headers.untag();

}

kind regards

Daniel (from Switzerland)

Translate
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
People's Champ ,
Oct 25, 2016 Oct 25, 2016

Indeed. You can't separate the table contents from the table structure. So tagging an inner content will tag the whole table and untag some inner content will untag the whole table.

Translate
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 Beginner ,
Mar 14, 2017 Mar 14, 2017
LATEST

Have you tried setting up table and cell styles for the document? you can set up an xslt to apply those upon import.

Translate
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