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

JavaScript XML object, InDesign XML object, XSLT

New Here ,
Oct 17, 2018 Oct 17, 2018

Hi,

I've been reading through the documentation and can see that you can load and manipulate an XML file using the JavaScript XML object. This object doesn't look like it has any methods for applying/mapping paragraph or character styles to elements. For this, I need to use the InDesign XML object, but this object doesn't look best suited for manipulating XML!

If my reading is correct, it looks like I should manipulate the XML with the JavaScript XML object, save out as an XML file, then load the XML back into the InDesign XML object to apply styles. Is this correct?

Alternatively, it looks like I could manipulate the XML with XSLT (outside of InDesign), assign the aid:pstyle and aid:cstyle attributes, load into InDesign and away I go.

I'd be interested to know whether my assumptions are correct and how others tackle their XML workflows.

Many thanks.

--

Jon

TOPICS
Scripting
2.2K
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

correct answers 1 Correct answer

People's Champ , Oct 17, 2018 Oct 17, 2018

From a strictly XML workflow point of view, you can do whatever you do in UI regarding to XML with scripting but you may be confused about how methods and properties are dispatched through the InDesign Object Model.

If you want to map styles to tags or the other way around, you need to use  XMLImportMap a/o XMLExportMap instances which belong to a document instance. You probably already know of placeXML which is a method of either a document, the app or some XMLElement instance. That will help lo

...
Translate
People's Champ ,
Oct 17, 2018 Oct 17, 2018

From a strictly XML workflow point of view, you can do whatever you do in UI regarding to XML with scripting but you may be confused about how methods and properties are dispatched through the InDesign Object Model.

If you want to map styles to tags or the other way around, you need to use  XMLImportMap a/o XMLExportMap instances which belong to a document instance. You probably already know of placeXML which is a method of either a document, the app or some XMLElement instance. That will help loading the xml file indeed while taking care of possibly set XMLImportMaps instances.

You can XMLImportPreferences if for example you are using XSLT or want to set any particular options.

With a combination of those properties and methods, you should be able to set your own xml workflow.

And for the mention, there is also a XML object which is pure ExtendScript and has nothing to deal specifically with XML import inside InDesign.

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
New Here ,
Oct 18, 2018 Oct 18, 2018

Hi Loic,

Many thanks for your reply.

I had a play around with the InDesign XML model and managed to import XML, map tags to styles, add text content before and after elements and place the XML in a frame (The Adobe Scripting Guide examples helped).

Then I moved onto tables. Ouch! My table elements are not in the CALS or HTML model, so it looks like I would need to wrap them in the appropriate 'table', 'row' and 'cell' elements before converting to a table. That's strange, because elsewhere I thought I read that Indesign has no concept of 'rows' in the table model, only cells! Anyway, some of my cells need merging, but it looks like this can only be achieved after the XML elements have been converted to a table. Is this right? Seems like conversion via XSLT prior to import may be a cleaner solution.

Kind regards.

--

Jon

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 18, 2018 Oct 18, 2018

hi,

jonh22247530  a écrit

That's strange, because elsewhere I thought I read that Indesign has no concept of 'rows' in the table model, only cells!

Indeed, there are no "row" nodes but may specify row count attribute in the table syntax (cf aid:trows="5"). As for merged cells, you can set aid:crows and aid:ccols attributes for Cells Nodes.

When I have some blanks, I usually draw a simple table inside InDesign, tag it and export to XML then i can find back all attributes I need. Should you do XSLT over scripting on this topic is really up to you. But XSLT may save some resources.

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
New Here ,
Oct 18, 2018 Oct 18, 2018
LATEST

Hi Loic,

Thank you for your replies and suggestions, it's appreciated.

Regards.

--

Jon

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