How to place the images in Indesign xml file by Javascript?

How to place the images in Indesign xml file by Javascript?
We got the Indesign xml file, how to give the image placement link by Indesign javascript? Please help me its urgent.

Hi,
You can pass the image url as a href attribute=> file:///Users/me/Documents/my_pic.jpg directly within your xml. It just needs that you pass a local, static and valid url.
If you want to add image later once the xml is flowed and so target specific nodes and inject images, it's a bit more complex. If the node is not part of the layout, you may try to reach the XMLElement objet and such an attribute, then layout the element.
var x = some XMLElement
x.xmlAttributes.add("href","file:///Users/m/Documents/my_pic.jpg" );
If already placed, then you have to get the associated pageItem, then place your file into it.
pagItm.place ( File ( "/Users/m/Documents/my_pic.jpg" ) );
Hope that helps,
Loic
http://www.loicaigon.com

Similar Messages

  • How to write the nodevalue back to xml file?

    Hi, Everybody:
    These are two packages I used. javax.xml.parsers.*,org.w3c.dom.*
    Now I use "setNodeValue("abc") to set the node value to "abc". But it is not really saved back into XML file. It only change the node value in memory.
    How to write the changes back to XML file? Thank you very much for your help.
    Michelle

    * Version : 1.00
    * File Purpose : Given the xml file loads into dom and recreate the file with the updated values.
    * Developer : Kashif Qasim : 25/july/04
    * Modify detail :
    import java.lang.*;
    import java.io.*;
    import java.util.*;
    import java.text.*;
    import org.w3c.dom.*;
    import org.apache.xerces.parsers.DOMParser;
    import org.apache.xerces.*;
    public class XMLWriter
    private String displayStrings[] = new String[5000];
    private int numberDisplayLines = 0;
    private Document document;
    //private final Node c;
    public synchronized void displayDocument(String uri,Vector UpdatedValues,String getTaskID)
    try {
    DOMParser parser = new DOMParser();
    parser.parse(uri);
    document = parser.getDocument();
    display(document, "",UpdatedValues);
    } catch (Exception e) {
    e.printStackTrace(System.err);
    ReadXmlConfig objReadXmlConfig = null;
    FileWriter filewriter = null;
    try {
    filewriter = new FileWriter(uri);
    for(int loopIndex = 0; loopIndex < numberDisplayLines; loopIndex++){
    filewriter.write(displayStrings[loopIndex].toCharArray());
    //System.out.println("displayStrings[loopIndex].toCharArray() "+displayStrings[loopIndex].toString());
    //filewriter.write("\n");
    filewriter.close();
    System.gc();
    objReadXmlConfig = new ReadXmlConfig();
    objReadXmlConfig.ITSLog("File updated for "+getTaskID+" succesfully, file is closed now ");
    } catch (IOException e) {
    System.err.println("Caught IOException: " + e.getMessage());
    objReadXmlConfig = new ReadXmlConfig();
    objReadXmlConfig.ITSErrorLog("File updated FAILED for "+getTaskID+". Reason for file error "+e.toString());
    }finally {
    if (filewriter != null) {
    System.out.println("Closing File");
    objReadXmlConfig =null;
    try{
    filewriter.close();
    }catch(IOException e){
    System.err.println("Caught IOException: " + e.getMessage());
    } else {
    System.out.println("File not open");
    private void display(Node node, String indent, Vector UpdtRecs)
    if (node == null) {
    return;
    int type = node.getNodeType();
    NodeList nodeList = document.getElementsByTagName("QueryParm");
    int TotalRecs = UpdtRecs.size();
    switch (type) {
    case Node.DOCUMENT_NODE: {
    displayStrings[numberDisplayLines] = indent;
    displayStrings[numberDisplayLines] +=
    "<?xml version=\"1.0\" encoding=\""+
    "UTF-8" + "\"?>";
    numberDisplayLines++;
    displayStrings[numberDisplayLines] += "\n";
    display(((Document)node).getDocumentElement(), "",UpdtRecs);
    break;
    case Node.ELEMENT_NODE: {
    if(node.getNodeName().equals("QueryParm")) {
    for(int i =0 ; i< nodeList.getLength() ; i++)
    Node nodeQry = nodeList.item(i);
    NamedNodeMap nnp = nodeQry.getAttributes();
    for(int j= 0 ; j < nnp.getLength() ; j++)
    Attr atr = (Attr) nnp.item(j);
    if(atr.getName().equalsIgnoreCase("value_"+(i+1)))
    //System.out.println(atr.getName() +" : " + atr.getNodeValue() );
    atr.setNodeValue(UpdtRecs.get(i).toString());
    displayStrings[numberDisplayLines] = indent;
    displayStrings[numberDisplayLines] += "<";
    displayStrings[numberDisplayLines] += node.getNodeName();
    int length = (node.getAttributes() != null) ?
    node.getAttributes().getLength() : 0;
    Attr attributes[] = new Attr[length];
    for (int loopIndex = 0; loopIndex < length; loopIndex++) {
    attributes[loopIndex] = (Attr)node.getAttributes().item(loopIndex);
    for (int loopIndex = 0; loopIndex < attributes.length; loopIndex++) {
    Attr attribute = attributes[loopIndex];
    displayStrings[numberDisplayLines] += " ";
    displayStrings[numberDisplayLines] += attribute.getNodeName();
    displayStrings[numberDisplayLines] += "=\"";
    displayStrings[numberDisplayLines] += attribute.getNodeValue();
    displayStrings[numberDisplayLines] += "\"";
    displayStrings[numberDisplayLines]+=">";
    numberDisplayLines++;
    NodeList childNodes = node.getChildNodes();
    if (childNodes != null) {
    length = childNodes.getLength();
    indent += " ";
    for (int loopIndex = 0; loopIndex < length; loopIndex++ ) {
    display(childNodes.item(loopIndex), indent,UpdtRecs);
    break;
    case Node.CDATA_SECTION_NODE: {
    displayStrings[numberDisplayLines] = "";
    displayStrings[numberDisplayLines] += "<![CDATA[";
    displayStrings[numberDisplayLines] += node.getNodeValue();
    displayStrings[numberDisplayLines] += "]]>";
    numberDisplayLines++;
    break;
    case Node.TEXT_NODE: {
    displayStrings[numberDisplayLines] = "";
    String newText = node.getNodeValue().trim();
    if(newText.indexOf("\n") < 0 && newText.length() > 0) {
    displayStrings[numberDisplayLines] += newText;
    displayStrings[numberDisplayLines] += "\n";
    numberDisplayLines++;
    break;
    case Node.PROCESSING_INSTRUCTION_NODE: {
    displayStrings[numberDisplayLines] = "";
    displayStrings[numberDisplayLines] += "<?";
    displayStrings[numberDisplayLines] += node.getNodeName();
    String text = node.getNodeValue();
    if (text != null && text.length() > 0) {
    displayStrings[numberDisplayLines] += text;
    displayStrings[numberDisplayLines] += "?>";
    displayStrings[numberDisplayLines] += "\n";
    numberDisplayLines++;
    break;
    if (type == Node.ELEMENT_NODE) {
    displayStrings[numberDisplayLines] = indent.substring(0,
    indent.length() - 4);
    displayStrings[numberDisplayLines] += "</";
    displayStrings[numberDisplayLines] += node.getNodeName();
    displayStrings[numberDisplayLines] += ">";
    displayStrings[numberDisplayLines] += "\n";
    numberDisplayLines++;
    indent += " ";
    public static void main(String args[])
    Vector xmlValue = new Vector();
    xmlValue.add(0,"Kashif");
    xmlValue.add(1,"Qasim");
    //displayDocument("NewMediation.xml",xmlValue);
    <?xml version="1.0" encoding="UTF-8"?>
    <Mediation>
    <Task1>
    <Source>
    <SourceDriver>com.microsoft.jdbc.sqlserver.SQLServerDriver</SourceDriver>
    <SourceConnection>jdbc:microsoft:sqlserver://10.2.1.58:1433;DatabaseName=MTCVB_HDS;</SourceConnection>
    <SourceUser>sa</SourceUser>
    <SourcePassword>sa</SourcePassword>
    <Table>
    <SourceTable>t_Agent</SourceTable>
    <SourceQuery><![CDATA[SELECT SkillTargetID,PersonID,PeripheralID,EnterpriseName,PeripheralNumber,Deleted,TemporaryAgent,AgentStateTrace,ChangeStamp FROM t_Agent where SkillTargetID > {value_1} order by SkillTargetID]]>
    </SourceQuery>
    <SourceParm BusinessRule="" ColumnName="SKILLTARGETID" ColumnNumber="1" DataType="Numeric" DefaultValue="0" Format="mm/dd/yyyy xx:xx:xx XX">
    </SourceParm>
    <SourceParm BusinessRule="" ColumnName="PERSONID" ColumnNumber="2" DataType="String" DefaultValue="" Format="">
    </SourceParm>
    <SourceParm BusinessRule="" ColumnName="PERIPHERALID" ColumnNumber="3" DataType="String" DefaultValue="" Format="">
    </SourceParm>
    <SourceParm BusinessRule="" ColumnName="ENTERPRISENAME" ColumnNumber="4" DataType="String" DefaultValue="" Format="">
    </SourceParm>
    <SourceParm BusinessRule="" ColumnName="PERIPHERALNUMBER" ColumnNumber="5" DataType="String" DefaultValue="" Format="">
    </SourceParm>
    <SourceParm BusinessRule="" ColumnName="DELETED" ColumnNumber="6" DataType="String" DefaultValue="" Format="">
    </SourceParm>
    <SourceParm BusinessRule="" ColumnName="TEMPORARYAGENT" ColumnNumber="7" DataType="String" DefaultValue="" Format="">
    </SourceParm>
    <SourceParm BusinessRule="" ColumnName="AGENTSTATETRACE" ColumnNumber="8" DataType="String" DefaultValue="" Format="">
    </SourceParm>
    <SourceParm BusinessRule="" ColumnName="CHANGESTAMP" ColumnNumber="9" DataType="String" DefaultValue="" Format="">
    </SourceParm>
    <QueryParm FldName_1="SkillTargetID" FldType_1="Number" value_1="0">
    </QueryParm>
    </Table>
    </Source>
    </Task1>
    </Mediation>
    The QueryParm values are updated thru this code :)
    Hope it helps u ...

  • How to get the encoding of a XML file ...

    Hi,
    How do you get the encoding of a XML file?
    For example,
    <?xml version="1.0" encoding="SJIS"?>
    I am trying to retrieve the above encoding="SJIS", but I can't seem to locate the API for doing so.
    Thanks in advance for any help,
    Eric

    Hi ddossot,
    Thanks for your suggestion.
    However, the xerces.jar file that comes with my old tomcat server is an old version and thus, the getEncoding method is not even present in the DocumentImpl class. The option to update to a newer version of tomcat and xerces is not available. What a pity... :-(
    Well, I just have to try to find a way around. Worst case scenario, parse the first line in the xml file myself.
    Regards,
    Eric

  • How to modify the priority of UWL XML File??

    Hello,
    How do you modify the priority of a UWL generated XML file? Ths xml file was generated when I registered the SRM system in UWL.
    I tried using the tab, Universal Worklist Configuration -> Upload new Configuration but it gives an exception "Operation not allowed".
    The reason for doing this,
    Conflicting ItemTypes are defined in the SRM XML file and one of the pre-defined SAP XML file (uwl_erp2005_buyer), and the SRM XML file has a priority of "Low" compared to medium priority for the erp xml. I need to change the SRM XML priority to "HIGH".
    Any help is appreciated.
    Thank you, John

    Erwin,
    Thanks for your reply.
    I downloaded the xml file, modifed some content. While uploading with the same name, making it a high priority and selecting the required system from the dropdown, "Adapt to System", it gives the following error
    Wed Apr 08 15:50:47 CDT 2009 : Operation not allowed on UWL generated Configuration:uwl.webflow.SAP_SRM_IAC
    Any reason the system does not allow doing this?
    John Miller

  • How to change the attributes of an XML file

    hi peeps 'ope you can help me here i need to change the attributes of an xml file, i parse it first using a DOM parser but i cant find a way to change the attributes in the XML file, setAttribute() works only at runtime and doesn't change the attribute in the file itself. I can't find a method that will answer my question. I've searched through the forum and found similar threads....they say in order to write and change the attribute i must use the write() method of the XmlDocument class defined in com.sun.xml.tree.XmlDocument. But, i found another thread, and it says that com.sun.xml.tree.XmlDocument is not safe to use and i should use org.apache.crimson.tree.XmlDocument.....i can't find the XmlDocument class and the API for this package so i really dont know where to start...hope you guys can help me! thnx

    thanks for responding roland....i already found the solution...i didn't use the XmlDocument class because i can't find any documents about it except for JAXP 1.0 here is my code snippet...i used the TransformerFactory and Transformer class to write
    import org.w3c.dom.*;
    import org.w3c.dom.traversal.*;
    import javax.xml.parsers.*;
    import javax.xml.transform.*;
    import javax.xml.transform.dom.*;
    import javax.xml.transform.stream.*;
    Document doc = null;
    DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
    DocumentBuilder db = dbf.newDocumentBuilder();
    dbf.setValidating(false);
    doc = db.parse(fileGetFile); //this is the XML file
    n1 = (Node)doc.getDocumentElement();
    e1 = (Element) n1;
    NodeList nodeList = doc.getElementsByTagName ("File");
    //just insert whatever you want to do with the XML...parse it..set/change the attribute..etc....sample snippet below changes the attribute downloaded to "no"
    for(int iWriteFailed = 0; iWriteFailed <nodeList.getLength() ; iWriteFailed ++){     
    n2 = nodeList.item(iWriteFailed);
    e2 = (Element) n2;          
    e2.setAttribute("downloaded", "no");}
    try{
    TransformerFactory transformerFactory = TransformerFactory.newInstance();
    Transformer transformer = transformerFactory.newTransformer();
    transformer.transform(new DOMSource(doc), new StreamResult ( new FileOutputStream ( fileGetFile) ) );}
    catch(Exception trans){}
    thanks for responding and keeping the information interchange alive here in the forum...
    Pau

  • How to get the number from a xml file to flash as3 Text Box "Get_Days"?

    Hi,
    I have to daily update the number of days finished from the specified days. Say, One work to be finished in 30 days. And the start day is today. So, tomorrow it will be 29 days left. and so on....
    So, instead of reducing one number everyday from the last days number using flash, it will be easy changing in xml file.
    How can I do that?
    I have a simple text box "dynamic text box" and the instance name : "Days_Left". Since I am learner, I cannot make complex projects. I am learning small things with very few lines of code which can be modified using xml files.
    So, Whatever I type in a xml file, it should appear in a text box called "Days_Left".
    Thanks.

    then you can use:
    var currentDate:Date = new Date(); 
    // this is today's date
    var projectDueDate:Date = new Date(2010,11,29); 
    // use whatever date you want for the due date.
    // months are zero-based.  (ie, jan is month 0, dec is month 11.)
    var daysToCompleteProject:Number = (projectDueDate.getTime()-currentDate.getTime())/(1000*60*60*24);
    // this is number of days between currentDate and projectDueDate.  you probably want to round or use days:hours:minutes for your display

  • Help on how to read the content of an XML file from the payload

    I have a receiver channel / mail adapter, that sends e-mails with a XML attachment.
    I’m trying to write a Bean, that should make it possible to rename the attached XML file dynamically.
    In the Bean I want to read the content of the attached XML file, it could be the “order number”.
    The filename should then be “Order number”.XML.
    <u><i>Can anyone help me with how to read the content of the XML file from the payload.</i></u>
    <i><b>Frank</b></i>

    hi,
    check this: http://jakarta.apache.org/poi/

  • How to import the data from a xml file to IDM

    Hi all:
       I have read  the document(/people/kare.indroy/blog/2008/01/14/sap-netweaver-identity-management-how-to-maintain-xml-files) ,but
    cannot get the data when I click the insert template-->data source template menu.
    The xml file as follows:
    <?xml version="1.0" encoding="GB2312"?>
    <users>
    <user>
    <name>CA_admin</name>
    <password>123</password>
    <role>caadmin</role>
    </user>
    <user>
    <name>CA_user1</name>
    <password>123</password>
    <role>caadmin</role>
    </user>
    </users>
    The xsl file as follows:
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:template match="users"> 
    <xsl:element name="users">      
                    <xsl:for-each select="user"> 
                     <xsl:element name="user">
                      <xsl:element name="name">               
                          <xsl:value-of select="name"/>
                      </xsl:element>
                      <xsl:element name="password">               
                           <xsl:value-of select="password"/>
                      </xsl:element>
                      <xsl:element name="role">               
                          <xsl:value-of select="role"/>
                      </xsl:element>
                      </xsl:element> 
                    </xsl:for-each>
                     </xsl:element>            
    </xsl:template>
    </xsl:stylesheet>
    Is there some thing wrong within my xsl file? Who can give me some points about this?
    Is there some more information about this topic?
    thanks in advanced.

    Hello Shi,
    Could you please provide details about how did you solve this problem?
    Thanks,
    Anuj

  • How to change the image of a selected File/Directory in JFileChooser while

    Hi all,
    I am trying to customize JFileChooser. Basically, I want to display a checked Icon for a selected directory(s) in JFileChooser
    I know that fileView class returns icon for directory/files, but I am not sure how to change their images on selection.
    your help is appreciated.
    Ramesh

    could you please anyone help me with this. I search all the web but I was not successful to find anything that would help me to create a custom renderer for JList component inside JFileChooser..
    if you can give me some reference websites that would be great.
    Ramesh

  • How to get the "encoding" of a XML file using JDOM

    As in XML file, <?xml version="1.0" encoding="UTF-8" ?> indicates the encoding of this file
    while using JDOM to parse a XML file, how can I get the encoding type?
    thanx!!!

    What my program do is to get the encoding of XML files and convert them to UTF-8 encoding files, while I need this "encoding" information of the original XML document thus I can convert...
    After reading specifications and JDOM docs, the truth turns to be disappointed, no function is provided to get this information in JDOM level 2(the current released one), while it's promissed that this function will be provided in JDOM level API....
    Thanx all for your help and attention!!!

  • How to change the output directory of .xml files

    Hi,
    There are lots of .xml files generated under
    $ORACLE_AS_HOME/j2ee/home/applications/xmlpserver/xmlpserver/xml.
    (ex:/usb/bipub3/oracle/oc4j_bi/j2ee/home/applications/xmlpserver/xmlpserver/xml).
    I found these files are generated in the following operation;
    1.Log in BI Publisher.
    2.Select the Schedules tab.
    I think they are kind of temp files so we will be able to delete them.
    But I'd like to know how to change the output directory.
    Can we change the above directory to other path?
    Regards.

    Why? As that may invalidate support since you configure/alter the deployment.
    The location is specified in oc4j_bi\j2ee\home\applications\xmlpserver\xmlpserver.war, so you could go into the war file and alter it.

  • How to read the extended-cache-config.xml file. in C++ API

    I want to create my own XML config file and define the config values in that, so that C++ Client (using Coherence C++ API) application can access the config files.
    Also how to get the instance of configuration values which Coherence client has read,
    i.e.
    TangosolCoherenceOverride=$PATH/examples/config/tangosol-coherence-override.xml
    TangosolCoherenceCacheconfig=$PATH/examples/config/extend-cache-config.xml
    How to get the instance of this XMLDocument ? and read values from it.
    Thanks,
    Naveen

    Hi,
    You can get the cache-config that was read by getting it from the ConfigurableCacheFatory (which you can get from the CacheFactory) via getConfig(). See:
    http://download.oracle.com/otn_hosted_doc/coherence/352CPP/classcoherence_1_1net_1_1_cache_factory.html
    http://download.oracle.com/otn_hosted_doc/coherence/352CPP/classcoherence_1_1net_1_1_configurable_cache_factory.html
    There is no way to get the actual XmlDocument object from the cluster that is read for the cluster-config (though you could open the same path yourself).
    thanks,
    -Rob

  • How to format the text in an XML file

    This should be a fairly easy one. A fairly easy one that seems to be hard to actually find.
    When I write out the XML file, it's all on a single line. Not a huge problem all things considered (it works), but an annoying one.
    Here's the a snippet, to show what I'm doing. There's not enough information for this to actually compile, if one is so inclined, just comment out a bunch of things and have it write out aribitary data.
    Is this a case where I just need to manually write the formating myself?
    public void saveXML(File file){
            try{
                Document doc = DocumentBuilderFactory.newInstance().
                    newDocumentBuilder().newDocument();
                //give that document a root
                Element root = doc.createElement("root");
                doc.appendChild(root);
                Command[] command=getCommands();
                for (int index=0; index < command.length; index++){
                    Element element = doc.createElement("Command");
                    root.appendChild(element);
                    //get the name of the parser class this command should use
                    String pName=command[index].getParser().getClass().getName();
                    //remove everything but the last word
                    pName=pName.substring(JavaMUServer.PARSER_PATH.length());
                    //set the information.
                    element.setAttribute("name",
                        command[index].getName());               
                    element.setAttribute("parser",pName);               
                    element.setAttribute("method",
                        command[index].getMethod().getName());
                TransformerFactory tFactory =TransformerFactory.newInstance();
                Transformer transformer = tFactory.newTransformer();
                DOMSource source = new DOMSource(doc);
                StreamResult result = new StreamResult(
                    new FileWriter(file));
                transformer.transform(source, result);
            }catch (Exception e){
                e.printStackTrace();
        }

    Well, that helped quite a bit. Seems however when I set the indent property, rather then indenting it just makes new lines. Rather counter intuitive.
    Here's the slightly modified code (changed one line really. Tried setting a few different properties.)
    public void saveXML(File file){
            try{
                Document doc = DocumentBuilderFactory.newInstance().
                    newDocumentBuilder().newDocument();
                //give that document a root
                Element root = doc.createElement("root");
                doc.appendChild(root);
                Command[] command=getCommands();
                for (int index=0; index < command.length; index++){
                    Element element = doc.createElement("Command");
                    root.appendChild(element);
                    element.appendChild(doc.createElement("sample"));
                    //get the name of the parser class this command should use
                    String pName=command[index].getParser().getClass().getName();
                    //remove everything but the last word
                    pName=pName.substring(JavaMUServer.PARSER_PATH.length());
                    //set the information.
                    element.setAttribute("name",
                        command[index].getName());               
                    element.setAttribute("parser",pName);               
                    element.setAttribute("method",
                        command[index].getMethod().getName());
                TransformerFactory tFactory =TransformerFactory.newInstance();
                Transformer transformer = tFactory.newTransformer();
                transformer.setOutputProperty("indent", "yes");
                //transformer.setOutputProperty("method", "xml");
                DOMSource source = new DOMSource(doc);
                StreamResult result = new StreamResult(
                    new FileWriter(file));
                transformer.transform(source, result);
            }catch (Exception e){
                e.printStackTrace();

  • How to conver the oracle data into xml files

    Hi All,
    I have a table for ex emp, now i want to generate every row into an xml file. could anyone pls help...
    ex:- emp table
    eno ename sal
    1    bond  3000
    2    kiran    2000
    3    jai       1000
    4    henry   500
    o/p :-  i have to get a column in 4 different files for this 4 rows.
    1.xml file        should contain data  <ID>1</ID><eNAME>bond</eNAME><sal>3000</sal>
    2.xml file        should contain data  <ID>2</ID><eNAME>kiran</eNAME><sal>2000</sal>
    3.xml file       should contain data  <ID>3</ID><eNAME>jai</eNAME><sal>1000</sal>
    4.xml file       should contain data  <ID>1</ID><eNAME>bond</eNAME><sal>500</sal>
    regards,
    Badri.

    You can do it like this :
    begin
      for r in (
          select empno
               , xmlserialize(content xmlforest(empno as "ID", ename, sal)) as xmlcontent
          from scott.emp
      loop
        dbms_xslprocessor.clob2file(r.xmlcontent, 'TEST_DIR', to_char(r.empno) || '.xml');
      end loop;
    end;

  • How to ignore the DTD in an XML file

    I am using XMLReader as
    XMLReader parser = XMLReaderFactory.createXMLReader("org.apache.xerces.parsers.SAXParser");
    to parse an xml document. The XML has a <!DOCTYPE ....> in it which specifies a dtd file. If I do not have the dtd file on my local machine, the parser will fail. How can I tell the parser to ignore the <!DOCTYPE..> line, since I do not want it to validate against the dtd anyway?
    Thanks.

    just comment out the <!DOCTYPE> element and you will not have any problem and moreover the default behaviour of xerces is not to validate but see the well formedness .If you want to validate the xml document then do this
    parser.setFeature("http://xml.org/sax/features/validation" ,true);
    this will validate.
    hope this will help you

Maybe you are looking for