2 Replies Latest reply on Apr 11, 2015 11:38 AM by beh_gras_beh

    XML Export with XSLT

    beh_gras_beh Level 1

      Dear scripters,

       

      With this little script you can export XML.

      But is there an way you can use an XSLT to export the XML?

       

      var w = new Window ("dialog");  
      var myBut = w.add ("button", undefined, "EXPORT", {name: "ok"});  
      var myName = app.activeDocument.name.split(".indd").join(".xml");  
      if (w.show() == 1){  
          try {  
               var myFolder = Folder.selectDialog("Select the folder", "");   
               app.scriptPreferences.userInteractionLevel=UserInteractionLevels.neverInteract;  
               var myInxfile = new File(myFolder.fsName+"/"+app.activeDocument.name.split(".indd")[0]+".xml");  
               app.activeDocument.exportFile(ExportFormat.XML, myInxfile);  
               } catch(err) {alert(err);}  
           }  
      app.scriptPreferences.userInteractionLevel = UserInteractionLevels.INTERACT_WITH_ALL; 
      

       

      XSLT:

      <?xml version='1.0' encoding='UTF-8' ?>
      <xsl:stylesheet version='1.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform'>
      <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>  
      
      
      <!-- Match everything -->  
      <xsl:template match="@*|node()">  
      <xsl:copy>  
      <xsl:apply-templates select="@*|node()" />  
      </xsl:copy>  
      <xsl:text>  
      </xsl:text></xsl:template>  
        
      </xsl:stylesheet>  
      

       

      Greetings