[CS3 JS] How to associate text with an XML tag

Hello,
I have a script that allows one to create or modify an XML tag after one selects text, a text frame or an existing XML tag. It works fine for making the XML tag but it does not associate the text or text frame to the tag. To do that I have to right click on the selection and use the context menu to Tag Text or Tag Frame.
I want to make this automatic but cannot see how to script it.
Thanks for any help

I figured out the problem (which of course creates other interesting problems).
In the line:
var elementRef = rootElement.xmlElements.add (tagRef);
I forgot to add a reference to the xmlContent. It should read:
var elementRef = rootElement.xmlElements.add (tagRef, whatToTag);
However, this script is designed to create a dialog box where one can either create a tag along with attributes or edit an existing one. I'll post it when I am done, but there is one hangup. The script not only changes the name of a selected xml tag but all tags with the same name. How can I get it to change only the selected tag? Below is the boiled down script that duplicates that problem.
Thanks,
Tom
var myDoc = app.activeDocument;
var selObj = app.selection[0];
var TagIWantToChange = selObj.markupTag;
var newTagName = "PleaseWork"; //This line replaces all the coding to create a dialog box where the tag name could be edited.
TagIWantToChange.name = newTagName;

Similar Messages

  • How to highlight text with Adobe Reader XI?

    email [email protected]

    Thanks. The PDF file was made from a web site article and I guess this is the same as scanned as I cannot highlight.  The cursor changes but cannot highlight what I want.
    I was able to add text and I did this in Red and will ask the VA to read under the sections marked in Red.
    Thanks,
    Vernon Pobanz
          From: ~graffiti <[email protected]>
    To: vernon pobang <[email protected]>
    Sent: Tuesday, October 7, 2014 11:57 AM
    Subject:  How to highlight text with Adobe Reader XI?
    How to highlight text with Adobe Reader XI?
    created by ~graffiti in Adobe Reader - View the full discussionUse the highlight tool under Comment>Annotations. This will only work if the pdf isn't a scanned image. If that is the case, there is no text to highlight. Please note that the Adobe Forums do not accept email attachments. If you want to embed a screen image in your message please visit the thread in the forum to embed the image at https://forums.adobe.com/message/6800192#6800192 Replies to this message go to everyone subscribed to this thread, not directly to the person who posted the message. To post a reply, either reply to this email or visit the message page:  To unsubscribe from this thread, please visit the message page at . In the Actions box on the right, click the Stop Email Notifications link.  Start a new discussion in Adobe Reader by email or at Adobe Community For more information about maintaining your forum email notifications please go to http://forums.adobe.com/thread/416458?tstart=0.

  • How do I text with the iPad 2 using cellular device?

    How do I text with the iPad 2 using cellular device? I also have iPhone 4, can I use them both for texting?

    The iPad doesn't have any text over cellular capabilities. You can use apps like Text Free to send texts to non-iOS devices, though.

  • [JS CS3] Problem with iterating xml tags

    Hello,
    Below is a script that is supposed to find text in a document and then tag it with an xml tag. I have run into a problem, which if I solve in the way I know how, causes another problem.
    When I iterate in a positive direction--i++--the first instance of the text (in this example "abc") is correctly tagged. But the second instance the tag recedes by two characters, that is, tags the three characters prior to the "c." A third instance will recede two more characters, ad nauseam, if my Latin is correct.
    The solution is to iterate backwards, i.e., i--. But this causes another problem. If there is more than one story, then the xml structure reverses the order of the stories. The elements within a story are ordered correctly however.
    So why is this happening and how can I solve it?
    Thanks,
    Tom
    var myDoc = app.activeDocument;
    var findABC = theTextFinder(myDoc,"abc");
    xmlTagIt(myDoc,"abc",UIColors.RED,findABC);
    //*****functions*******
    function xmlTagIt(docRef, tagName,colorOfTag, arrToTag){
        var tagName, colorOfTag,  arrToTag;
        myDoc.xmlViewPreferences.showStructure = true;
        myDoc.xmlViewPreferences.showTaggedFrames =true;
        myDoc.xmlViewPreferences.showTagMarkers = true;
        myDoc.xmlViewPreferences.showTextSnippets =false;
        myDoc.xmlPreferences.defaultStoryTagColor = UIColors.WHITE;
        var rootElement = myDoc.xmlElements.item(0);
        if (myDoc.xmlTags.item(tagName) == null) {
            var tagRef = myDoc.xmlTags.add(tagName, colorOfTag);
      } else {//if tag already exists then stop the script. Avoid double tagging
           myDoc.xmlViewPreferences.showStructure = true;
           alert("You have already run this script.");
           exit();
       }//end else
        //for (var i = arrToTag.length-1; 0 <= i; i--){
        for (var i = 0; i <= arrToTag.length-1;  i++){
            var elementRef = rootElement.xmlElements.add (tagRef,arrToTag[i]);       
         }//end for i
    }//end function xmlTagIt
    function theTextFinder(docRef,textFindIt){//last argument is the string of text to find
        app.findTextPreferences = NothingEnum.NOTHING;
        app.changeTextPreferences = NothingEnum.NOTHING;
        app.findTextPreferences.findWhat = textFindIt;
        var arrTextFindIt = myDoc.findText();
        return arrTextFindIt;
    }//end theTextFinder

    Dave,
    Thanks for the reply.
    I'm not sure what you mean by "convert the references on the fly." You mean find a way to advance two characters forward and tag that? In the script I submitted here I am only searching for "abc," which of course I would not search or at all  in real life. The script uses grep to search for about twenty different typographical errors that typically appear and tags them all.
    Reiterating backwards seems, at first sight the way to go. But I haven't a clue as to how to reverse the order of the stories. I can get an array of stories, and array.reverse() them, but am not sure how to then make the script put this reversed order into the xml structure. Any hints?
    There, of course is bigger problem with the stories. If the document is written with one story created after another then the order of them is top to botom. But if say a text frame edited into the middle of all this, that story is still the last one in the xml structure. At least in one test, that was so. Maybe the way to solve this is to build an array of stories that have as one xml attribute the page it first appears on. Then order the array according to that attribute.
    Any advice you give will be appreciated.
    Thanks,
    Tom

  • HTTP Receiver Adapter payload as single line plain text with out any tags.

    Hi PI experts,
    I have a strange problem in http receiver adapter.
    Sender RFC (SAP)  Receiver: HTTP.
    Receiver system expects the output from XI in the below format in a single line plain text with out any tags in the payload. and the content type should be application/x-www-form-urlencoded
    Group=Test&Sentinel=Web%20Server&Facility=5345&Order Number=XT-XWHM-Y-NA&Serial Number=123456&@LABEL_QUANTITY=5&@LABEL_NAME=111114_Q
    Is there any way to achieve this using http receiver adapter. Business is not ready to accept the output from XI not even in a single element instead they only need it as a JUST a plain text.
    Appreciate early response on this.
    Thanks in Advance,
    Jitender

    Dear Ola,
    Could you elaborate how you achieved in catching the response data from the receiver in case of HTTP receiver adapter?
    The target service is not a WebService but some python script that must to receive some paramters via POST request.
         HOW can I post this parameters?
    Here you entered the fields of the message type of the request in the header parameters of the receiver adapter? Thats fine.
    But what about the message type and vice versa of the response from the receiver?
    Regards
    Rebecca

  • Alert Content for text without any XML tag

    Hi All,
    For the XML workflow,
    Need a alert content or select content for the text without any xml tag.
    Please help for my XML job request.
    Regards
    Siraj

    Hi All,
    New to XML, just learning stage only.
    Already I asked and got the coding through forum. It alert text frame ID only.
    But, guide me how to get the
    1. alert or select the contents.
    2. alert the page number or select text frame etc.
    Coding is below:
    #target InDesign
    #include "/Applications/Adobe InDesign CS6/Scripts/Xml Rules/glue code.jsx"
    main();
    exit();
    function main() {
              var myDoc = app.activeDocument;
              var myStories = myDoc.stories.everyItem().getElements();
              var idArray = new Array(0);
              var storyArray = new Array(0);
              // store all stories of the document in an array
              for(var j=0; j < myStories.length; j++) {
                        storyArray.push(myStories[j].id);
    // *** here start the XML-Rules ******************************//
              var elements = myDoc.xmlElements;
              var myRuleSet = new Array(
                        alleObj = new all(idArray)
              __processRuleSet(elements.item(0), myRuleSet);
    // *** here stop the XML-Rules *******************************//
              for (var i=0; i < idArray.length; i++) {
                        for (var k=0; k < storyArray.length; k++) {
                                  if (idArray[i] == storyArray[k]) {
                                            storyArray[k] = -1;
              for (var i=0; i < storyArray.length; i++) {
                        if (storyArray[i] > 0) {
                                  alert(storyArray[i]);
                        }          // if …
              }          // for()
    }          // main()
    // XML-Rule
    function all(idArray) {
              this.name = "all";
              this.xpath = "//*";
              this.apply = function(myElement, myRuleProcessor) {
                var storyId = myElement.parentStory.id;
                        var i=0, found = false;
                        while ((i < idArray.length) && (!found)) {
                                  if (idArray[i++] == storyId) found=true;
                        // store anly the number of the stories which are not stored up to now
                        if (!found) idArray.push(storyId);
                return true;
              }          // this.apply
    }          // all()
    Regards
    Siraj

  • How to apply paragraph styles to xml tag?

    Hi All,
    How to apply paragraph style to xml tag?

    Hi Learner,
    Try the below js code.
    var myDoc = app.activeDocument;
    try{
        mySel=app.selection[0];
        myDoc.xmlElements[0].xmlElements.add({markupTag:"TEST", xmlContent:mySel});
        }catch(e){
            alert(e);
    var myDocument = app.activeDocument;
    app.findGrepPreferences.appliedParagraphStyle = "test";
    app.findGrepPreferences.findWhat = ".+(?=\\r)"
    var mySearch = myDocument.findGrep(false);
    for (a=0; a<mySearch.length; a++){
        myDocument.xmlElements[0].xmlElements.add({markupTag:"TEST", xmlContent:mySearch[a]});
    thx,
    csm_phil

  • How to use Euro symbol in xml tags?

    How to use Euro symbol in xml tags?

    What do you mean by "in xml tags"? Can you post a three-line XML snippet showing what you hope to achieve?

  • How to style text with XML import using character style that is in a group (aid:cstyle = "group1"."style1") ?

    Hello, I am using an XML file to import text into InDesign page items. Everything works well using the attribute "aid:cstyle = style1" but since the introduction of InDesign groups, our users want to use them but we do not know how to reference them in the xml attribute.
    I saw somewhere on the internet that you should use "aid:cstyle = group1:style1" or "aid:cstyle = group1|style1" but both won't work. They simply create a new ungrouped style name "group1:style1" or "group1|style1"
    So what is the right formula ?
    Thanks

    Tagged Text is nice but all the copy in your page item is one big block, no way to separate and track individual values, say in your page item you have a description and a sale price, you can't update the price without reimporting the description as well. We use many fields inside an individual page item and just as one example we need to be able to update all prices on the page without modifying anything else that shares the page items with the prices. Also XML updates you can trigger an update for the whole document in one operation, while with Tagged Text you have to "place" your text file for each individual page item you are modifying (even with scripting you call the place function as many times as you have page items). So say you have a page or document with 200 boxes across multiple layers that is a lot of individual actions.
    Anyway back to my problem.
    I've never used Mapping tas to styles before, but running some tests here I clearly don't understand it. If my text is already tagged and I map a style to a tag, it untags all my individual text elements and leaves only the page item tag, and doesn't style my text... I'm going to try and read more on this.

  • How I creatat text with hyperlink in application

    hi all,
    I want to creat some text with hyperlink (it mean when I click to text, it invoke other panel or web...). My program is Application. Can any one tell me how I do it. Pls help me!!!.
    Thank you verry much

    Is this text HTML? If so, just go to any of the 350,000 sites on the Internet that describe basic HTML. Otherwise, just output the URL as text.
    However my guess is that your bigger problems are (a) how to notice the hyperlink is clicked and (b) how to invoke whatever it links to. Right?

  • How to associate tips with controls?

    Hi All,
    Is there any way to associate tips with control?
    When my application is running,when the user drags over his mouse on the control,is there any way to s[ecify the purpose of the control.
    ie,if i have a button called "plot",whenever the user drags his mouse over "plot"i want to display a tip indicating that this button's purpose is to plot graph.
    IIs there any way like that?
    Thanks

    Just Rt Click on the Numeric ( or whatever )-->> Description & Tip... thats it.
    Tip will come as tool tip when you run the VI. Description will offer you a detailed help when you do Ctrl+H while running the VI.
    Hope this helps you in more detail.
    - Partha
    LabVIEW - Wires that catch bugs!

  • How do you text with other people not on an iPad or I phone?

    Can you text with other phones beside iPhone?

    Open the blue App Store icon and type it into the top right, plenty there to choose from.

  • How to read data with different XML schemas within the single connection?

    I have Oracle 11g database
    I access it through jdbc:oracle:thin, version 11.2.0.3, same as xdb.
    I have several tables, each has one XMLType column, all schema-based.
    There are three different XML schemata registered in the DB
    I may need to read the XML data from several tables.
    If all the XMLTypes have the same XML schema ,there is no problem,
    If the schemata are different, the second read throws BindXMLException.
    If I reset the connection between the reads of the XMLType column with different schemata, it works.
    The question is: how can I configure the driver, or the connection to be able to read the data with different XML schemata without resetting the connection (which is expensive).
    The code to get the XMLType data is textbook implementation:
    1   ResultSet resultSet = statement.executeQuery( sql ) ;
    2   String result = null ;
    3    while(resultSet.next()) {
    4   SQLXML sqlxml = resultSet.getSQLXML(1) ;
    5   result = sqlxml.getString() ;
    6   sqlxml.free();
    7   }
    8   resultSet.close();
    9    return result ;

    It turns out, that I needed to serialize the XML on the server and read it as Blob. Like this:
    1    final Statement statement = connection.createStatement() ;
    2    final String sql = String.format("select xmlserialize(content xml_content_column as blob encoding 'UTF-8') from %s where key='%s'", table, key ) ;
    3   ResultSet resultSet = statement.executeQuery( sql ) ;
    4   String result = null ;
    5    while(resultSet.next()) {
    6   Blob blob = resultSet.getBlob( 1 );
    7   InputStream inputStream = blob.getBinaryStream();
    8   result = new Scanner( inputStream ).useDelimiter( "\\A" ).next();
    9   inputStream.close();
    10   blob.free();
    11   }
    12   resultSet.close();
    13   statement.close();
    14
    15   System.out.println( result );
    16    return result ;
    17
    Then it works. Still, can't get it work with XMLType in resultset.On the client unwrapping XML blows up when trying to switch to different XML schema. JDBC/XDB problem?

  • How to get a text between two XML tags?

    Hello everybody!
    I've got a problem! How can I extract a text that is between tags, like <myTag> My text </myTag> I have no problem to get the attributes inside the tags, however, i don't know how to get some text that is between tags. Here is my xml:
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <tangram_request service_id="3">
    <send keep_session="nada">
    <source></source>
    <destination>3196931566</destination>
    <channel_id>2</channel_id>
    <text>Teste ServerSocket!!!</text>
    </send>
    </tangram_request>
    Now, there's a fragment of my code, which gets some tags' attributes:
    DOMParser parser = new DOMParser();
    InputSource resp = new InputSource(new StringReader(XML));
    parser.parse(resp);
    Document doc = parser.getDocument();
    Node node =(doc.getElementsByTagName "tangram_request")).item(0);
    if (node instanceof Element)
    Element el = (Element) node;
    service_id = el.getAttribute("service_id");
    System.out.println("\n\nService_id="+service_id);
    }else{System.out.println("Erro");}
    node = (doc.getElementsByTagName("send")).item(0);
    if (node instanceof Element)
    Element el = (Element) node;
    keep_session = el.getAttribute("keep_session");
    System.out.println("keep_session="+keep_session);
    }else{System.out.println("Erro");}
    Now, I want to get the texte between <destination> ... </destination>
    How could I do that?
    Thanks a lot
    Calegari

    Thanks... It worked fine!!!
    Now how can I get lots of <desctination>... I did something that haven't worked...
    node = (doc.getElementsByTagName("destination")).item(0);
    while(node.hasChildNodes())
    destination = node.removeChild(node.getFirstChild()).getNodeValue();
    System.out.println("destination="+destination);
    And now, my XML is like:
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <tangram_request service_id="3">
    <send keep_session="nada">
    <source></source>
    <destination>3196931566</destination>
    <destination>3196931567</destination>
    <channel_id>2</channel_id>
    <text>Teste ServerSocket!!!</text>
    </send>
    </tangram_request>
    Thanks so much!
    Calegari

  • How to insert Text physically to xml in xml Element

    hello friends,
    I am newb of jDom. i am trying to change xml "Element's"--->"Text". My xml is as follows .....
    <?xml version ="1.0">
    <Elements>
             <code>
                       <data>EE550</data>
             </code>
    </Elements> I am trying to replace that "<data>" by <data>AA550</data>
    my code is as below
                 SAXBuilder sb = new SAXBuilder();
                 Document doc = sb.build(new File("src/xml/M90EE.xml"));
                 Element element = doc.getRootElement();
                 List children = element.getChildren();
                 String key = (element.getChild("text").getChild("mkey").setText("AA550").getTextTrim());   System.out.println("mkey       :"+key);
    output:
    mkey   :AA550 but is it possible to change in the xml file phisically.
    thanQ
    Ajay

    hello Reegz,
    ThanQ so much for perfect solution....
    when i do like that it is actually adding text to the existing Element Text.. so i wrote as follows....
    SAXBuilder sb = new SAXBuilder();
    Document doc = sb.build(new File("src/xml/M90EE.xml"));
    *String skey = (element.getChild("text").getChild("mkey").removeContent().toString());*     //--------->step 1
    *String skey1 = (element.getChild("text").getChild("mkey").addContent("ISO9001").toString());* //-------->step 2     
    String rdmkey = (element.getChild("text").getChild("mkey").getTextTrim());
    XMLOutputter serializer = new XMLOutputter();
    String str = serializer.outputString(doc);
    FileWriter fr = new FileWriter("src/xml/M90EE.xml");
    fr.write(str);
    fr.flush();
    fr.close();Is there any other way to replace text in step1 and step2 other than above or will it be enough for multiuser programming. Because this application will be accessed by so many number of user's what do u sujjest.
    thanQ ...
    Han.

Maybe you are looking for

  • Looking for handy Alarm app!

    I am looking for a very small, small, compact, simple application that sits in the menu bar and allows me to set a time at which it will remind me of something. (ex.: taking an eye-break, taking food out of the oven, etc..) No, iCal doesn't cut it (a

  • How can I make slides NOT advance automatically?

    I'm building a project manually by making new slides and putting graphics and text on them.  It's not a recording of software.  I would like the user to read each slide for as long as they want to, then click to go to the next one.  I can't find a se

  • Is there any OOB way to aggragate content in SPF (Foundation)?

    Is there any OOB way to aggragate content in SPF (Foundation)? I don't see even CQWP in the WP... (Content Search  is not included in this version. am i right?) keren tsur

  • Oracle 9i and ...

    other platform than rh or suse .... I try to install oracle 9i on linux slackware 8.0 and linux debian woody (both distr are based on glibc 2.2.3). I try - because install is fail on runInstall. My question is: si possible to install oracle 9 on this

  • Deletion of co document

    Hi all can we delete a co document after posting in fi without deleting the corresponding fi doc thanks