简体   繁体   中英

Breaking one XML file into multiple XML files with XSLT 1 for InDesign

Good morning all,

Within InDesign, I am trying to create multiple database records with XML with this structure:

<Root>
     <record>
     </record>
     <record>
     </record>
</Root>

I have the XML exporting perfectly, but I'd like to apply XSLT to break this separate files for each record, with record as the root for each. Ex:

File1.xml:
<record>
</record>

File2.xml:
<record>
</record>

I have Googled and seen people say that you cannot use the XSLT 2.0 functions with the InDesign export function. Is it possible to do this with XSLT 1.0?

Thank you!

I don't think so with the InDesign XSLT engine. A script on contrary could work by exporting to xml teh specific nodes:

 var main = function() { var root, records, f, n, doc; if ( !app.documents.length ) return; doc = app.activeDocument; root = doc.xmlElements[0]; records = root.evaluateXPathExpression ( "./record" ); n = records.length; while ( n-- ) { f = File ( Folder.desktop+"/"+doc.name.replace (".indd", "")+"_"+(n+1)+".xml" ); records[n].exportFile ( ExportFormat.XML, f ); } } main(); 

Loic is correct, InDesign uses XSLT 1.0 engine, I think it is still the case for CC 2015.

An alternative option would be exporting XML untransformed and run external script calling XSLT 2.0 engine of your choice to transform XML.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM