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

Script access to dataset variables

New Here ,
Jul 16, 2014 Jul 16, 2014

Copy link to clipboard

Copied

Hello,

I've added some dynamic text variables to an illustrator file (CC), captured the dataset and I'm trying to access these variable values through scripting.

Is this possible with the Dataset method or do I need to parse the XML to retrieve info between <Book></Book> etc?

I've hacked together a perl script to do this, but it's not ideal as I need to then use javascript to call applescript to run the shell script with administrator privileges!

I'm sure there must be an easier way – any help would be much appreciated. Exported XML file is as follows...

<?xml version="1.0" encoding="utf-8"?>

<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20001102//EN"    "http://www.w3.org/TR/2000/CR-SVG-20001102/DTD/svg-20001102.dtd" [

     <!ENTITY ns_graphs "http://ns.adobe.com/Graphs/1.0/">

     <!ENTITY ns_vars "http://ns.adobe.com/Variables/1.0/">

     <!ENTITY ns_imrep "http://ns.adobe.com/ImageReplacement/1.0/">

     <!ENTITY ns_custom "http://ns.adobe.com/GenericCustomNamespace/1.0/">

      <!ENTITY ns_flows "http://ns.adobe.com/Flows/1.0/">

<!ENTITY ns_extend "http://ns.adobe.com/Extensibility/1.0/">

]>

<svg>

<variableSets  xmlns="&ns_vars;">

      <variableSet  locked="none" varSetName="binding1">

          <variables>

               <variable  trait="textcontent" category="&ns_flows;" varName="Book"></variable>

               <variable  trait="textcontent" category="&ns_flows;" varName="Author"></variable>

               <variable  trait="textcontent" category="&ns_flows;" varName="Year"></variable>

          </variables>

          <v:sampleDataSets  xmlns:v="&ns_vars;" xmlns="&ns_custom;">

               <v:sampleDataSet  dataSetName="Data Set 1">

                    <Book>

                         <p>Catch-22</p>

                    </Book>

                    <Author>

                         <p>Joseph Heller</p>

                    </Author>

                    <Year>

                         <p>1961</p>

                     </Year>

                </v:sampleDataSet>

          </v:sampleDataSets>

     </variableSet>

</variableSets>

</svg>

TOPICS
Scripting

Views

2.0K
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

correct answers 1 Correct answer

Community Expert , Jul 16, 2014 Jul 16, 2014

here's an easier way

var idoc = app.activeDocument;

var vars = idoc.variables;

for (j=0; j<vars.length; j++)

    alert(vars.name + ' : ' + vars.pageItems[0].contents);

Votes

Translate
Adobe
Community Expert ,
Jul 16, 2014 Jul 16, 2014

Copy link to clipboard

Copied

here's an easier way

var idoc = app.activeDocument;

var vars = idoc.variables;

for (j=0; j<vars.length; j++)

    alert(vars.name + ' : ' + vars.pageItems[0].contents);

Votes

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
New Here ,
Jul 17, 2014 Jul 17, 2014

Copy link to clipboard

Copied

LATEST

That is definitely an easier way. Thanks so much!

Votes

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