Open XML and using xslt with JavaScript

Hello,
I want the user to be able to choose an XML-file. This XML-file should not be placed in InDesign, there is not even a document needed for my script. All I need is a variable, containing the file. However, the XML-file should be transformed with xslt into another XML-file. How do I do this?
This is how I open the first XML-file, the one that should be transformed:
   var xmlDoc = File.openDialog ("Choose XML");
   if (xmlDoc == null) {return;}
    xmlDoc.open("r");
    xmlDoc = xmlDoc.read();
    xmlDoc = new XML(xmlDoc);
I can adress different nodes and use xmlDoc as an XML-file, so that's fine, but how do I transform it?
I read the Scripting Guide and tried this:
    var myDocument = app.documents.add();
    var myXMLImportPreferences = app.xmlImportPreferences;
    myXMLImportPreferences.transformFilename = "c:\myTransform.xsl";
    var xx = myDocument.importXML(File.openDialog ("XML"));
However, it's not exactly what I want since I have to create a document and it's not working either, since xx stays undefined.
Thanks for your help.

You can't get exactly what you want.
Your first code example uses the InDesign JavaScript interpreter's XML support, called E4X. It has absolutely nothing to do with the InDesign document object model or InDesign's internal support for XML. It exists only within the JavaScript interpreter. It does not support XSLT transformations.
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?

Similar Messages

  • Open and Close Popup With Javascript

    Using Apex 3.2
    I have probably done this loads of times in my old job, but do not have access to the code and today I just can't get it to work properly.
    I have opened a pop up window with javascript
    Now I need to close it and refresh the calling page, but only if it passes the validation on the popup.
    I have a hidden item on my pop up called P7_FLAG.
    I have a page process after validation that sets P7_FLAG to (only set to 1, if passes validation).
    I also have a SUBMIT button.
    So once I click my SUBMIT button the page should look at the validations, if ok, set P7_FLAG to 1, then close the popup and refresh the calling page.
    My current javascript look like this
    <script type="text/javascript">
    function saveChanges(){
    doSubmit('SUBMIT');
    var test = $x('P7_FLAG').value;
    if(test == '1')
    window.close();
    window.opener.doSubmit('REFRESH');
    </script>On my button
    javascript:saveChanges();The problem is that I need to click the SUBMIT button twice.
    First time it sets P7_FLAG
    Second time it closes page and refreshes.
    I have probably made some basic error, but today I cannot see it.
    Cheers
    Gus
    Edited by: Gus C on May 10, 2012 12:48 AM

    <script type="text/javascript">
    function saveChanges(){
    doSubmit('SUBMIT');
    var test = $x('P7_FLAG').value;
    if(test == '1')
    window.close();
    window.opener.doSubmit('REFRESH');
    </script>javascript does not wait for the current action to complete and then perform the next line.
    means in your function call
    doSubmit('SUBMIT');is triggered and it carry on's to next line that is
    $x('P7_FLAG').value;this will not be set because you are setting the value of P7_FLAG to 1 in plsql and trying to check in javascript, which will not work.
    what you need to do is amend your js function like below
    <script type="text/javascript">
    function saveChanges(){
    doSubmit('SUBMIT');
    </script>create a page branch to procedure and make it conditional to when P7_FLAG = 1
    and set the branch source to below
    htp.p('window.close();');
    htp.p('window.opener.doSubmit(''REFRESH'');');

  • How to update XML file using XSLT

    Hi there,
    I have a "small" issue with exporting data to an XML file using XSLT.
    A two steps process is needed to import data from a non-hierarchical XML file into ABAP, change the data, and then update the XML file with new values. The problem is not trivial, since the format of the XML file is a complex one: there are many interdependent elements on the same level, pointing to each other by using id and ref attributes. Based on these values the data can be read and written into an internal table. I use XSLT and XPath for that. So the inbound process is done and seems to work correctly. I have to mention that the file contains much more data than I need. I am working only with a small part of it.
    Now the changed data must be exported back into the XML file, meaning that the content of certain elements must be updated. How can this be done with XSLT? I can pass only the internal table to the transformation, so how do I access the XML file in order to update it? I have tried to use the <B>xsl:document()</B> function to access the content of the file store locally on my PC, but it fails each time by throwing and URI exception. I have tried the absolute path without any addition and the path with the file:/// addition. Same result. Please advise.
    Many thanks,
    Ferenc
    P.S. Please provide me with links only if they are relevant for this very matter. I will not give points for irrelevant postings...

    Now the changed data must be exported back into the XML file, meaning that the content of certain elements must be updated. How can this be done with XSLT?
    XSLT approach:  check these online tutorial
    http://www.xml.com/pub/a/2000/08/02/xslt/index.html
    http://www.xml.com/pub/a/2000/06/07/transforming/index.html
    ABAP approach:
    for example you have the xml (original) in a string called say xml_out .
    data: l_xml  type ref to cl_xml_document ,
            node type ref to if_ixml_node  .
    create object l_xml.
    call method l_xml->parse_string
      exporting
        stream = xml_out.
    node = l_xml->find_node(
        name   = 'IDENTITY'
       ROOT   = ROOT
    l_xml->set_attribute(
        name    = 'Name'
        value   = 'Charles'
        node    = node
    (the above example reads the element IDENTITY and sets attribute name/value to the same)
    like wise you can add new elements starting from IDENTITY using various methods available in class CL_XML_DOCUMENT
    so how do I access the XML file in order to update it?
    you have already read this XML into a ABAP variable right?
    Sorry couldnt understand your whole process, why do you need to read local XML file?
    Raja

  • Acrobat form on Ipad - form field to open camera and use photo in field?

    If I am using a acrobat form on an Ipad can I set a required field to open the camera, take a photo, and place the photo in the field?

    It's possible, but not with Reader for iOS. The only PDF viewer for iOS that I know it can be done with is Readdle's PDF Expert. You can set up a button with a layout other than "Label Only", and use the following JavaScript in the button's Mouse Up event:
    // Mouse Up script
    event.target.buttonImportIcon();
    It will allow you to take a picture or use an image from a photo library.

  • How can I add links to open xml and csv files stored in another location? Please advice how to place links in my frame maker document?

    Hi,
    I would like to know as to how can I add links to open xml and csv files stored in another location? Please advice how to place links in my frame maker document?
    Kindly advice.
    Thanks
    Priya

    Special > Hypertext > Command "open document" will do its best to open the target document inside FrameMaker, which may not be much help; Special > Hypertext > Command "message …" will use the application you specify. The user guide for 7.0 says this about absolute links, and I don't think anything has changed since:
    For example, to start PaintBrush and open the Ship.pcx file on drive C you would use the command message system pbrush.exe C:/Ship.pcx
    I've not often used a relative link, and not recently: the same source says
    folder levels are separated by a slash / even in Windows and Mac
    [relative links] FrameMaker searches for a relative pathname beginning in the folder that contains the current document
    [absolute links] FrameMaker searches for an absolute pathname beginning at the top of the file system. In Windows, the absolute pathname begins with the drive specifier, a colon and a slash.

  • Is it possible for Apple Time Capsule place iphoto library and use it with my macbooks

    Is it possible for Apple Time Capsule place iphoto library and use it with my macbook pro & macbook air? How about the simultaneous use? Will I as well open it in my ipad and iphoto?

    How Come? I thought that to an external drive move iphoto library is not a problem  -  https://discussions.apple.com/thread/3012995?tstart=0. And Apple Time Capsule including the an external drive.

  • I have bought a new airport express and using it with my macbook (iTunes 10.2.2). I have joined an existing network for internet in my home and with that i am trying to play the music via itunes but there is audio dropouts every 60 secs or so. any soln ?

    I have bought a new airport express and using it with my macbook (iTunes 10.2.2). I have joined an existing wireless network for internet in my home and with that i am trying to play the music via itunes but there is audio dropouts every 60 secs or so. I am using a set of speakers from kenwood connected to the airport express. The operating system on my macbook is mac os X 10.5.8. i am sure it is not a problem of streaming music online because i have even tried playing music which are stored in my macbook.
    Is there any problem with the setting in itunes or quicktime ? Kindly reply...... I am waiting for your valuable suggestion.
    Thank you a lot in advance.

    I am shocked to have found this same AX audio dropout problem starting TODAY, every few seconds the audio just drops for a couple seconds and then resumes:  Latest software versions of everything.  No iPad, iPhone or Touch.  Internet hardwired to D-Link DES1105 (1000baseT Switch) hardwired to new 80211N AX, AX optical to stereo, AX Wi-Fi internet to basic 1st-gen MacBook operating at 80211G, and an older 'G' AX extender at the far end of the house, away from all this.  The MacBook streaming iTunes is usually 12 feet from AX.  I've used this setup for years of trouble-free AirTunes / Airplay until today.  Today I also found 2 very reliable fixes and 1 way to force a dropout, but first, I read some posts and tried ALL following settings one-at-a-time and restored them ALL because NONE of them helped:  Turned off IPV6.  Streamed to multiple speakers 'Computer' and 'AX' (restored to just AX).  Turned off 'Ask to Join new (WiFi) Networks'.  Turned off Bluetooth (can't live without Magic Trackpad, so glad that wasn't it).  Here's my discoveries:  Lo and behold, each time I click the Airport icon in the Menu (you know it shows you've got 4 bars from AX) when the status switches to 'Looking for Networks' for a second it CAUSES the AX audio to drop out for a couple seconds (it never did that before today.)  iTunes still playing, streaming, AX laser still lit, but the 'PCM' light on stereo and the sound GOES OUT EVERY time I click the Airport icon in the menubar, just like the regular, annoying dropouts.  So, to reduce traffic I quit Safari (3 tabs, no streaming, just Gmail, Google, and Netflix browsing).  Lo and behold, the dropouts stopped altogether.  No other Web apps going (not iTunes Store, Genius, Ping, nothing), so I launched Chrome to the same 3 tabs and the dropouts HAVE NOT RETURNED.  That's right, not only did simply QUITTING SAFARI cure it, and Chrome doesn't contribute to it, but I can demonstrate it just by forcing my Airport to re-scan.  Works for me, written using Chrome.  The other reliable fix is to hardwire MacBook to the Switch.  This is obviously not ideal, but Airplay audio doesn't drop out over Ethernet.  Also, in all my tests, it made no difference whether iTunes did the streaming, or Airfoil did.

  • For the 2013 versions of macbook pro should I purchase 32 bit windows or 64 bit version to be able to install it on macbook and use windows with bootcamp?

    for the 2013 versions of macbook pro should I purchase 32 bit windows or 64 bit version to be able to install it on macbook and use windows with bootcamp?

    Then you might check at any of the other university book stores or software stores or any computer store in town for the 64-bit version.
    If you want to use the 32-bit version from the school (you probably get it for free or very cheap) then you could purchase Parallels and run it as a virtual machine concurrently with OS X. There are some caveats:
    1. You have to purchase Parallels (there may be an academic discount.) List is $79.95.
    2. Your computer needs minimally 4 GBs of RAM, but realistically 8 GBs would be better.
    3. Parallels creates a pseudo-drive on your hard drive. It could easily require 50 GBs of disk space.
    Accommodating these might be more costly than buying 64-bit Windows 7. And, if you look online you may find them with an academic discount (or may be able to order it through the school.)

  • How do I remove my phone number from my iphone so that i can continue to use it like an ipod touch and use imessages with email/apple ID?

    How do i remove my phone number from my iphone 4s so that i can continue to use it as an ipod touch and use imessages with email/apple ID?

    This article explains what to do:
    http://support.apple.com/kb/HT5661

  • My desktop IMac OSX 10.6.8 : IMovie '11: Trying to upload a home movie clip from my Panosonic camera model PV-DV203D. I've had this camera several years, and used it with Windows desktop. Now trying to work with my Mac. I have a USB cable, both ends fit,

    My desktop IMac OSX 10.6.8 : IMovie '11: Trying to upload a home movie clip from my Panosonic camera model PV-DV203D. I've had this camera several years, and used it with Windows desktop. Now trying to work with my Mac. I have a USB cable, both ends fit, but iMovie '11 does not recognize it. Is there a driver fix for this?

    What kind of Mac to you have?  This camera is a tape based DV one that connects best with firewire and I cannot tell if your Mac has firewire.  If your mac *does* have firewire, get a camcorder firewire cable and try again.
    ETA:  Oops, I am pretty sure that all the "desktop iMacs" have firewire, so you should be good to go.  You will probably need a cord that goes from FW800 to your camcorder.

  • When legally ipad2 with 3G would be available in Thailand?  Can I buy it from US and use it with 3G operator in Thailand?

    When legally ipad2 with 3G would be available in Thailand?  Can I buy it from US and use it with 3G operator in Thailand?

    The iPad 2 is available in Thailand now, though I don't know whether you can find one it stock. The iPad 2 continues to be in short supply everywhere in the world. A US iPad with GSM 3G should be able to work with any carrier worldwide that offers GSM service and a suitable data plan. You'll need to be sure you purchase the AT&T version of the iPad if you purchase in the US, NOT the Verizon version which uses a different cell technology.
    This has been asked and answered in these forums multiple times already, by the way. A quick search or browse of the forums and you would not have had to wait for a response.
    Regards.

  • Can I unlock my Droid Charge and use it with a sim card in India?

    How can I unlock my Droid Charge and use it with a sim card in India?

    You just have to call VZW Global TS and as long as you meet all of the requirments you will be able to unlock your phone.
    Must be a Verizon Wireless customer.
    The device being unlocked must be active on a VZW line of service.
    The line of service must be active for at least 60 days.
    For converted accounts from acquisitions or mergers (i.e. Alltel, Unicel/RCC, etc.), the line of service must be active in the VZW billing system for 60 days from the conversion date.
      The line of service must be in good standing for the past 60 days.  Good Standing is defined as:
    Balance must be current 
    No service suspensions or hotlines in the past 60 days.
    Customer may only have one 3G SIM unlock per line every 10 months.
    The customer's manufacturer's device warranty is not affected by a 3G SIM unlock as long as the customer remains with VZW.

  • Is it possible to connect an external camera via bluetooth to the Iphone 4 and use it with Facetime, if not.. why?

    Is it possible to connect an external camera via bluetooth to the Iphone 4 and use it with Facetime, if not.. why?

    Ok, in 2015 is it possible now? I would like to use an iPad and Face to share content between a dressmaker in Asia and a customer in the US, and I would like to attach better camera's than the built-in camera's on the devices.
    Any thoughts? Any updates to the original post?
    Thanks,
    James

  • If user disable cookie how to set and use session with URL Rewritting

    if user disable cookie how to set and use session with URL Rewritting by append session ID in url

    If cookies are disabled, then app server will automatically try to use URL rewriting for session control. Programmer's responsibility is to encode any links or redirects using
    response.encodeURL("/yourPage.jsp")
    and
    response.encodeRedirectURL("/yourPage.jsp")
    See API for details
    http://java.sun.com/j2ee/sdk_1.3/techdocs/api/javax/servlet/http/HttpServletResponse.html#encodeURL(java.lang.String))

  • I have dreamweaver in my adobe cre4atove cloud suite. How do I open it and use it

    I have dreamweaver in my adobe cloud suite. How do I open it and use it

    If you have installed it, it will be in your Program Files (PC) or Applications (Mac) folder.
    If you haven't installed it, you will need to open the Creative Cloud Application and click the Install button next to Dreamweaver under the Apps tab.

Maybe you are looking for

  • Ethernet down on AP1142 (IT IS CONNECTED)

    Hello everyone, This is my 1st ever post to the community. I have a weird problem. The set-up is as follows. WLC 5508 software version 7.0.116.0 DHCP server on windows 2008 R2 (works like a charm, invc. option 43, and 60) As soon as I connect AP 1142

  • Error bars on graphs

    I was desperately hoping that Apple would include the ability to add error bars to charts in this release. As a research faculty member, I simply cannot present data at conferences without having error bars on the graphs. It is a shame, because I hav

  • Opening a web overlay frame via button press (and closing it again)

    Hi all Is the following possible: Push a button A web content overlay window opens, displaying the web-based content within the frame (in this case, a URL pasted in from a google mobile search result). This window is smaller than the normal page size

  • VERY slow broadband speeds (0.76mbps) Phoneline?

    VERY slow broadband speeds (0.76mbps) Options  on 28-10-2012 12h38 ROUTER STATISTICS System Up Time: 0:08:24 Port Status TxPkts RxPkts Collisions Tx B/s Rx B/s Up TimeWANLANWLAN MER 2351 2177 0 136 104 0:00:56 324 0 0 0 0 0:08:24 6762 6743 0 164 132

  • Compressor is exporting clips that are too short in duration

    Hi, I am sending clips via FCP 7 into Compressor 3.5. The problem is that the outputted clips are too short in duration. Has anyone else had this problem? I need to fix it quick! Thanks, Phil.