Skip to main content
machipotHocine
Inspiring
April 14, 2015
Question

I have touble with 'mapStylesToXMLTags()' it freezes my InDesign... any idea? THANK YOU

  • April 14, 2015
  • 1 reply
  • 735 views

Hi,

Thank you for your help

This topic has been closed for replies.

1 reply

Loic.Aigon
Legend
April 15, 2015

Let me grab my crystal ball…

More chance to get help if you give some details

machipotHocine
Inspiring
April 15, 2015

 

Hi Loic,

 

 

Here is a portion of my code,

 

The script freezes at the second line (this.document.mapStylesToXMLTags();)

 

       // ---------------------------------------

        trace("Update XML Structure and get rootElements >>>");

        this.document.mapStylesToXMLTags();

 

      

I tried to extract each paragraphStyle, I got 3 paragraphs with the following code:

 

var myDocument = app.activeDocument;

       for (var myCounter = 0 ; myCounter < myDocument.paragraphStyles.length; myCounter++){

var myParagraphStyle = myDocument.paragraphStyles.item(myCounter);

var myParagraphStyleName = myParagraphStyle.name;

var myXMLTagName = myParagraphStyleName.replace(/\ /gi,"_");

myXMLTagName = myXMLTagName.replace(/\[/gi,"");

myXMLTagName = myXMLTagName.replace(/\]/gi,"");

 

var myXMLTag = myDocument.xmlTags.add(myXMLTagName);

myDocument.xmlExportMaps.add(myParagraphStyle,myXMLTag);

}

 

myDocument.mapStylesToXMLTags();

 

       

 

Result:

 

  1. [No Paragraph Style] ----converted to --à No_Paragraph_Style
  2. [Basic Paragraph Style] ----converted to --à Basic_Paragraph_Style
  3. [xmlTable] ----converted to --à xmlTable

  

 

ERROR @ line : var myXMLTag = myDocument.xmlTags.add(myXMLTagName);

A tag with that name already exists. Please chose a different name.

 

Thank you, and let me know if you require more details

 

Loic.Aigon
Legend
April 15, 2015

Hi,

Just check item validity prior to possibly adding the object :

var myXMLTag = myDocument.xmlTags.item(myXMLTagName);

!myXMLTag.isValid && myXMLTag = myDocument.xmlTags.add(myXMLTagName);

Other point, I guess trace is a pseudo alert function. But what is this.document in your context ? Out of the blue, it's not a syntax that could possibly work inside Indesign Scripting space.

HTH,

Loic

http://www.ozalto.com