You can't get exactly what you want.
Your second example leverages InDesign's built-in XSLT support (I'm not too sure how this works...); but that is only useful when importing XML into
InDesign, which, as you have learned, requires a document.
In the first example, you could call out to an external invokation of xsltproc and read in the input. How to do that differs for Windows and Mac.
In the second example, you could export the XML from your Document back out to an XML file and read it back in with E4X.
None of this is very appealing. What do you really need to do?
Thanks for your answer.
I want to find out if some xml-elements are part of the transformed xml-file. I don't want the users to transform the file with some editor themself, because I'm afraid this might confuse them.
If one of the searched xml-elements is part of the transformed xml-file, it's written into a txt-file. However, it would propably be easier to work with the second idea, considering that each xml-element will later be translated into a paragraph style, which can be added to a new document. So basically one could say, I want to create a template based on the transformed xml-file. Also I'm not sure, which os will be used later, I'm working with windows right now.
I'm trying to import xml, with a xsl transformation.
And I'm using something similar to you : fixing the xmlimport preferences, etc
After impoting the xml try this!!!
myDocument.xmlImportPreferences.allowTransform = true;
myDocument.xmlImportPreferences.transformFilename = File("........................");\\give your xslt path
myDocument.xmlImportPreferences.importStyle = XMLImportStyles.MERGE_IMPORT;
myDocument.xmlImportPreferences.repeatTextElements = true;
myDocument.xmlImportPreferences.importCALSTables = true;
myDocument.xmlImportPreferences.importTextIntoTables = true;
myDocument.xmlImportPreferences.removeUnmatchedExisting = false;
But make sure your xslt should be xml version="1.0"
I tried that.
But before or after, no modifications...
And the xsl file is ok (I can import "by hand" with the menu import xml).