Hi everyone,
I have write a javacsript to export xml file from InDesign. For the pretty ptrint I use allowTansform and transformFilename with an xslt script to indent my exported files. But, I have find out an unexpexted behaviour of my script at the export time. My xml files aren't indented.
If I do first an export applying my xslt script by the user interface, the result is well done. Then after i use my javascript which it do nothing, It works well now. I don't see where is my misunderstood ?
i hope that I clearly makes me understand.
see my script :
function mySnippet()
{
with(app.xmlExportPreferences)
{
allowTransform = false;
// Préférences d'exportation au format XML
charactersReferences = true;
copyOptimizedImages = true;
exportFromSelected = true;
xmlFileEncoding = XMLFileEncoding.UTF8;
transformFilename= File ('../prettyPrintXML.xsl');
// Activation des variables locales
var xmlElement;
var myDocument = app.activeDocument;
var xmlRoot = myDocument.xmlElements[0];
myTagElement = xmlRoot.evaluateXPathExpression('//doc');
xmlElements = xmlRoot.evaluateXPathExpression('//doc//article//texte');
myAuthorRootTag = xmlRoot.evaluateXPathExpression('//composant-signature');
myAuthorTag = myAuthorRootTag[0];
myAuth = myAuthorTag.xmlContent.contents;
myAuth1 = myAuth.split(" ");
myAuthorFirstName = myAuth1 [1];
myAuthorLastName = myAuth1 [2];
myAuthor = myAuthorFirstName + ' ' + myAuthorLastName;
myIssueRootTag = xmlRoot.evaluateXPathExpression('//issuedate');
myIssueTag = myIssueRootTag[0];
myIssueDate = myIssueTag.xmlContent.contents;
alert (myAuthorFirstName + ' ' + myAuthorLastName);
alert (myIssueDate);
for (docPos = 0; docPos < myTagElement.length; docPos++)
{
xmlElement = myTagElement[docPos];
myArticle = docPos;
myDocPos = xmlElements[docPos].xmlContent.insertionPoints[0].parentTextFrames[0] ;
myPageName = + myDocPos.parentPage.name;
// Génération du fichier ".cont.xml"
myCont = myWorkFolder + '/' + myExportNameFile + '_' + myPageName.threeDigit() + '_' + myArticle.threeDigit() + '.cont.xml';
myFileCont = new File (myCont);
xmlElement.exportFile(ExportFormat.xml, myFileCont, false);
//Génération du fichier ".sys.xml"
mySys = myWorkFolder + '/' + myExportNameFile + '_' + myPageName.threeDigit() + '_' + myArticle.threeDigit() + '.sys.xml'
myFileSys = new File (mySys);
var myXMLElement = myDocument.xmlElements.item(0).xmlElements.item(-2);
myXMLElement.exportFile(ExportFormat.xml, myFileSys, false);
//Génération du fichier ".meta.xml"
myMeta = myWorkFolder + '/' + myExportNameFile + '_' + myPageName.threeDigit() + '_'+ myArticle.threeDigit() + '.meta.xml';
myFileMeta = new File (myMeta);
var myXMLElement = myDocument.xmlElements.item(0).xmlElements.item(-1);
myXMLElement.exportFile(ExportFormat.xml, myFileMeta, false);
}
}
}
thanks
Américo