[CS3][JS] Apply XML tag for selected text

Hi
  I need to apply XML tag to selected text in a tagged content.The XML tag is already applied for paragraph.I need to apply XML Tag for selected text in a paragraph.
I have used following code, it applies tag for entire paragraph,not a selected text in a paragraph.
app.selection[0].associatedXMLElements[0].markupTag=myDoc.xmlTags.item("italic");
Please suggest me.
Regards
kumar

The example script, markup.jsx
//Markup.jsx
//An InDesign CS4 JavaScript
//Shows how to use the markup method.
main();
function main(){
    mySetup();
    mySnippet();
    myTeardown();
function mySetup(){
    var myDocument = app.documents.add();
    var myPage = app.activeWindow.activePage;
    var myRootXMLElement = myDocument.xmlElements.item(0);
    var myXMLTag = myDocument.xmlTags.add("xml_element");
    var myXMLElementA = myRootXMLElement.xmlElements.add(myXMLTag);
    myXMLElementA.contents = "This is a paragraph in an XML story.";
    var myTextFrame = myPage.textFrames.add({geometricBounds:myGetBounds(myDocument, myPage)});
    myTextFrame.contents = "This is the first paragraph in a text frame.\rThis is the second paragraph in a text frame.\rThis is the third paragraph in a text frame.\rThis is the fourth paragraph in a text frame.\r";
function mySnippet(){
    //<fragment>
    var myDocument = app.documents.item(0);
    var myPage = myDocument.pages.item(0);
    myDocument.xmlElements.item(0).xmlElements.item(0).markup(myPage.textFrames.item(0));
    //</fragment>
function myTeardown(){
function myGetBounds(myDocument, myPage){
    var myPageWidth = myDocument.documentPreferences.pageWidth;
    var myPageHeight = myDocument.documentPreferences.pageHeight
    if(myPage.side == PageSideOptions.leftHand){
        var myX2 = myPage.marginPreferences.left;
        var myX1 = myPage.marginPreferences.right;
    else{
        var myX1 = myPage.marginPreferences.left;
        var myX2 = myPage.marginPreferences.right;
    var myY1 = myPage.marginPreferences.top;
    var myX2 = myPageWidth - myX2;
    var myY2 = myPageHeight - myPage.marginPreferences.bottom;
    return [myY1, myX1, myY2, myX2];
I think you can use the markup function on the selected item (Text Object have a markup method)
Thomas B. Nielsen
http://www.lund-co.dk

Similar Messages

  • Create new tag for selected text using API?

    Hello,
    I want to add new tag for the selected text just like 'Create Tag from selection' .
    is it possible to create tag for selected text using acrobat api?
         please,help me.

    As per sample of snippetRunner for adding tag for selected text.
    I tried below code
    PDPage pg;
    AVDoc avDoc = AVAppGetActiveDoc();
    PDDoc pd = AVDocGetPDDoc(avDoc);
        pg = PDDocAcquirePage(pd, 0);
    ASAtom theSelectionType = AVDocGetSelectionType(avDoc);
    if (theSelectionType == ASAtomFromString("Text")){
        PDTextSelect ts = static_cast<PDTextSelect>(AVDocGetSelection(avDoc));
        PDSTreeRoot pdsTreeRoot;
        CosObj pageObj = PDPageGetCosObj (pg);
        PDSElement newElem;
        PDSElementCreate(pd, &newElem);
        char buf1[64];
        strcpy (buf1, "A new structure element");
        // set its type as "Document" standard type
        PDSElementSetType(newElem, ASAtomFromString ("Document"));
        // set its title
        PDSElementSetTitle(newElem, reinterpret_cast<const ASUns8*> (buf1), strlen(buf1));
        PDSTreeRootInsertKid (pdsTreeRoot, aElem, kPDSAfterLast);
        PDSElementInsertMCAsKid // here something i have to add
    If i have PDTextSelect how i can add tag for selected text.like user add tag using "CreateTagForSelectedText" option.
    please,help me.
    thanks.

  • Tagging for selected Text

    Hi All,
    I am new in Illustrator and through scripting am trying to tag the each line in the text Frame. Same way as InDesign does - Frame Tag and Inline Text Tag.
    Is that possible? if so how and if no is there similar concept avialable in Illustrator which can be used?
    Thank you all in advance.
    Regards
    Farzana.

    Hi All,
    I am new in Illustrator and through scripting am trying to tag the each line in the text Frame. Same way as InDesign does - Frame Tag and Inline Text Tag.
    Is that possible? if so how and if no is there similar concept avialable in Illustrator which can be used?
    Thank you all in advance.
    Regards
    Farzana.

  • Generation of XML Tags for columns in Lexical parameter in select query

    Hi,
    I have lexical parameter in my select statement of my data model in the report.
    How do i generate XML tags for these columns inside a Lexical Parameter?
    Simple Example: I have data model query as follows:
    SELECT msi.inventory_item_id
    &LP_SELECT
    FROM mtl_system_items_b
    Here my lexical Parameter LP_SELECT is generated in before report trigger as follows in my report:
    :LP_SELECT := 'msi.segment1,msi.description';
    So, the question is how to generate XML Tags for columns in Lexical Parameter(as in the example above, i need XML tags for these columns - segment1 and description)
    Thanks,
    Ratan

    try this
    Select &order data_show
    from oe_order_headers_all
    where order_number ='7889'
    and setting  :order:='order_number';  in after parameter form trigger.
    Hope this helps
    Hamid

  • Getting xml tags for PO releases.

    I need some help in getting xml tags for PO releases.
    When I refer metalink they gave me the following for Std PO.
    Create a new Standard Purchase Order and DO NOT approve it. Let it be in Incomplete status. Go to
    concurrent requests and run the 'PO Output for Communication' concurrent
    program will the following parameters:
    Print Selection: All
    Purchase Order Number From: The PO # you just created
    To: The PO # you just created
    Test: Debug
    May I know for PO releases what are additional parameters.I tried to enter release numbers in addition to the above.Bit it did not work,..
    I am having issue in getting buyer contact phone for PO releases.So I am trying to see if the work_tele_phone is available for Po releases xml tags.
    Can anyone please advise
    prasamb

    To get the tag name, you can use the following XSL stylesheet:
    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:template match="node()">
    <xsl:value-of select="name()"/> <xsl:text> </xsl:text>
    <xsl:apply-templates/>
    </xsl:template>
    </xsl:stylesheet>

  • XML Element of selected text

    Hi,
    I need to get the tag name of bold applied in InDesign document.  When finding bold contents in InDesign document using Find Options, its select bold contents with some hidden text (tags) as shown in the below image.  If i use "select in structure" of selected text, its select wrong element (parent of all selected elements).  I need to get the correct XML Element of selected text (Except hidden character).  How can i get the element of selected text??
    Can anyone help me.
    - Sudha K

    Hi,
    I need to get the tag name of bold applied in InDesign document.  When finding bold contents in InDesign document using Find Options, its select bold contents with some hidden text (tags) as shown in the below image.  If i use "select in structure" of selected text, its select wrong element (parent of all selected elements).  I need to get the correct XML Element of selected text (Except hidden character).  How can i get the element of selected text??
    Can anyone help me.
    - Sudha K

  • How to get all xml tags in a text frame?

    I want to get all the xml tags of the text in a text frame. I had tried the following methods but always get the tag binding the frame itself. <br /><br />1) XMLReference objXMLRef = Utils<IXMLUtils>()->QueryXMLReferenceData(textModel, 1);<br /><br />2) XMLReference objXMLRef = Utils<IXMLUtils>()->GetStoryThreadXMLReference(textModel, textIndex);<br /><br />Thanks in advance.

    I would think if you intanciate the XMLReference and use IIDXMLElement GetChildCount / GetNthChild would do what you are looking for.
    Ian

  • PDF PO Release - XML Tags for the Header and Line Attachments

    Hi,
    I request you to please help me in finding out the XML tags for the PDF PO Release Header and Line Attachments? I tried to get the XML data by running the 'PO Output for Communication' program with the parameter as 'Debug' but its completing normally without giving me the XML data in the log file.
    Please help me in finding the XML tags for the PDF PO Release for the Header and Line Attachments.
    Thanks,
    Kunal

    Hi Kunal,
    Following syntax will get you the header and line level short and long text attachments.
    --Header short text attachments
    <?for-each:HEADER_SHORT_TEXT_ROW?>
         <?SHORT_TEXT?>
    <?end for-each?>
    --Header long text attachments
    <?for-each:/PO_DATA/HEADER_ATTACHMENTS/LONG_TEXT?>
         <?.?>
    <?end for-each?>
    --Line short text attachments
    <?for-each:LINE_SHORT_TEXT_ROW?>
         <?SHORT_TEXT?>
    <?end for-each?>
    --Line long text attachments
    <?variable@incontext:PoLnID;'PO_LINE_ID'?><?for-each:/PO_DATA/LINE_ATTACHMENTS/ID[. =$PoLnID]?>
         <?current()[$PoLnID]/preceding-sibling::TEXT[1]?>
    <?end for-each?>
    Also note that, while running the program in Debug mode for a particular PO/Release the status should be INCOMPLETE, otherwise you won't be able to see the XML tags.
    Thanks,
    PS.
    Edited by: PS on Sep 25, 2012 6:16 AM

  • Blue color for selected text

    Hello, is any way to change blue color for selected text which is the same as for invisible characters? When I select text all unvisible characters are realy unvisible... In old ID selected text was black and invisible characters inside was orange. Many thx for help... Ilja

    For sure I tried to use "select text" in Illustrator CC on the same system (windows 7) and selected text is black too...
    Many thx for help
    Ilja
    PS
    I must agree with the post about very slowly ID CC. I tried the same indd files in CS6 and CC and CC is slowly in large documents (500 pages and more), for ex. find/replace, but when document is near its end (aprox 80-100 pages) ID CC is much faster than at the start of document. Now I am working on large doc (540 pages) with many headers (aprox 3-4 on each page) and when I want change space for non-breaking space on pages between 1-100, this takes sometimes more than 2 seconds!!! Only simple space change - no styl change etc.
    I think that I am using fast PC (Intel i7, 16GB RAM, SSD disks - cache is on separated mSATA 30GB SSD), all doc are located inside PC, no external drives for normal day work) and I never seen these lags on CS6. Doesn't matter if I using ID CC 32 od 64 bit - it is aprox the same.

  • REST API XML tags for person extension fields

    We are trying to use REST API to create a person. We are able to update most of the data but am unable to find the right xml tags for Person Extension fields like custom1 etc. Could you please help?

    Hi !
    In the Account WSDL, you have the ListOfAddress object. If you are using it, filling the field "StreetAddress2" should work...
    Max

  • Error for fetching long text in xml tag for xml publisher report

    My requirement is to fetch a large document which is in text format in XML output which can be printed in PDF format by using RTF method to generate PDF.But during XML ouput i got the following error-
    The XML page cannot be displayed
    Cannot view XML input using XSL style sheet. Please correct the error and then click the Refresh
    button, or try again later.
    The following tags were not closed: XXBG_EAMWRREP_V1, LIST_G_WO_ACTIVITY_CODE, G_WO_ACTIVITY_CODE, LIST_G_MEDIA_ID1,
    G_MEDIA...
    XXBG_EAMWRREP_V1 is the rdf and LIST_G_WO_ACTIVITY_CODE, G_WO_ACTIVITY_CODE, LIST_G_MEDIA_ID1, G_MEDIA are the groups name. In the group
    G_MEDIA i am fetching long_text from attahcment in application. In Database table the datatype of the text attachment is 'long' and there is a huge text
    data loaded in large data editor of that column. If the text data volume is small enough then there is no problem for fetching the xml output.
    If we change the output format as HTMl then there is no problem for fetching the output for long text but for xml output format we are unable to fetch the data
    in xml tag.
    One thing to mention the oracle report is the copy of Maintenance Work Order Detail Report. The seeded report is HTML format in 11i. The requirement is to make it in xml report.
    Please help.

    Hi,
    Actually clob datatype is not available in oracle report builder datatype lov. Could you pls tell the other ways of converting that to clob in oracle report...

  • Embedding html in xml tags, when rednering text as html

    Quick question,
    I have a site that reads all content from an external xml.
    The text box that reads this info renders the content as html; does
    anyone know how to go about putting an html tag in an xml tag so
    that flash can read it?
    So would it be possible to do:
    <content>
    " Welcome to the site<br>we are happy to have you
    here<br><img src="logo.jpg"> "
    </content>

    I completed deleted the old way, so I have to recreate this
    from scratch...but here is how I used to be able to do it (which,
    looking at how I do it now since HTML wasn't parsing, this was so
    stupid).
    <chair id="1" price_point="High-end">
    <image>&lt;a
    href='/dsn/catalog/viewproductpage.asp?OwnerID=1&amp;PageID=%7B7A0FB858%2D2184%2D4033%2DB 474%2D2B22D89BBD96%7D'&gt;&lt;img
    src='/images/s/dshe/mini/7/79219.jpg border='0'
    /&gt;&lt;/a&gt;</image>
    <description>&lt;a
    href='/dsn/catalog/viewproductpage.asp?OwnerID=1&amp;PageID=%7B7A0FB858%2D2184%2D4033%2DB 474%2D2B22D89BBD96%7D'&gt;Toni&lt;/a&gt;</description>
    <brand>Kwalu</brand>
    <composition>Kwalu</composition>
    <leg_style>Chippendale</leg_style>
    <overall_style>Transitional</overall_style>
    </chair>
    And now in 1.1, having that, it prints this on screen:
    <a
    href='/dsn/catalog/viewproductpage.asp?OwnerID=1&PageID=%7B7A0FB858%2D2184%2D4033%2DB474% 2D2B22D89BBD96%7D'><img
    src='/images/s/dshe/mini/7/79219.jpg border='0' /></a>
    whereas before, it would be that image and it would link to
    the page specified in the href.
    I'm about to take off from work for the night, but I'll check
    back when I get home if you need anything else from me.
    Thanks for your help, Kin. :)
    Kyle

  • Pages '09: Can't use AppleScript for selected text inside tables?

    When I run get selection on selected text in a Pages document, I get something like this:
    <pre>text from character 1 to character 4 of body text of document id 9943974 of application "Pages"</pre>
    When I run get selection on selected text inside a table cell in a table in a Pages document, I get something like this:
    <pre>text from character 1 to character 4 of some table of document id 3539679 of application "Pages"</pre>
    When I run get selection on selected text inside a table cell in ANOTHER table in the same Pages document, I get the exact same thing. It still says "some" table. So there is no way to distinguish between tables if there are more than one table in the same Pages document.
    Am I correct in understanding that this means that most AppleScript commands for manipulating text are unusable inside table cells?
    For example, it seems impossible to get the properties of the selection when the selection is selected text inside "some" table. So it's impossible do anything about text styles, etc.
    Is AppleScript support in Pages ’09 really that limited, or am I missing something?

    The first script below should return the character style of any selection made in Pages ’09, whereas the second script should apply the "XXX" character style to any selection:
    --BEGINNING OF SCRIPT 1
    tell application "Pages"
    activate
    tell application "System Events" to tell process "Pages"
    -- Show the format bar:
    if not (pop up button 1 of window 1 exists) then
    click menu item "Show Format Bar" of menu 1 of menu bar item "View" of menu bar 1
    end if
    -- Show the styles drawer and character styles:
    if menu item "Show Styles Drawer" of menu 1 of menu bar item "View" of menu bar 1 exists then
    keystroke "t" using {shift down, command down}
    end if
    tell front window
    tell checkbox 1 of group 1 of drawer 1 -- “Show or hide character styles.” checkbox
    repeat until it exists
    delay 0.1 -- wait until the styles drawer is open
    end repeat
    if description is "show character style" then click
    end tell
    -- Get the row index (although it is not a property) of the character style:
    tell menu button 2 -- “Choose a character style.” menu button
    click
    set k to 0
    repeat
    set k to k + 1
    if value of attribute "AXMenuItemMarkChar" of menu item k of menu 1 exists then exit repeat
    end repeat
    keystroke return -- hide the menu
    end tell
    -- Get the character style name:
    if k > 1 then set k to k + 1
    value of static text 1 of row k of outline 1 of scroll area 2 of splitter group 1 of group 1 of drawer 1
    end tell
    end tell
    end tell
    --END OF SCRIPT 1
    --BEGINNING OF SCRIPT 2
    set myStyle to "XXX" -- the name of the character style you want to apply
    tell application "Pages"
    activate
    tell application "System Events" to tell process "Pages"
    -- Show the format bar:
    if not (pop up button 1 of window 1 exists) then
    click menu item "Show Format Bar" of menu 1 of menu bar item "View" of menu bar 1
    end if
    -- Show the styles drawer and character styles:
    if menu item "Show Styles Drawer" of menu 1 of menu bar item "View" of menu bar 1 exists then
    keystroke "t" using {shift down, command down}
    end if
    tell front window
    tell checkbox 1 of group 1 of drawer 1 -- “Show or hide character styles.” checkbox
    repeat until it exists
    delay 0.1 -- wait until the styles drawer is open
    end repeat
    if description is "show character style" then click
    end tell
    set characterStyles to value of static text 1 of rows of outline 1 of scroll area 2 of splitter group 1 of group 1 of drawer 1
    set k to 0
    repeat with thisStyle in the characterStyles
    set k to k + 1
    if thisStyle as text is myStyle then exit repeat
    end repeat
    -- Apply the character style:
    if k > 1 then set k to k - 1
    click menu button 2 -- “Choose a character style.” menu button
    click menu item k of menu 1 of menu button 2
    end tell
    end tell
    end tell
    --END OF SCRIPT 2
    I suppose that +paragraph styles+ should work the same.
    I'm beginning to know Pages ’09 a little better now.
    Message was edited by: Pierre L. (show format bar)

  • SetFont for selected text in JTextArea

    Hi there,
    I'm trying to build a small Texteditor.
    How do you set a selceted area of text to fx. BOLD font?
    I can of course set the font for the whole JTextArea via the setFont method, but what about a smal selection.
    Also: setFont seems to take no less than 3 arguments (fontname, style, size). Is it possible just to set the selected font as the same as before, but BOLD??
    Kind Regards
    Thomas

    Alright, so here I go :
    I've been working for two months on a TextEditor/HTMLEditor, but I'm not allowed to share my code (I work for a company that wants to use this editor).
    There are a lot of stuff that you should know about "javax.swing.text" package if you want to get initiated to Editors programming with Swing components.
    Well, first of all, I'm going to answer to your punctual question :
    You can't set style attributes ( color, bold, italic, ...) to specifc text elements in a JTextArea, you have got to use a JEditorPane or a JTextPane. (JTextPane lets you deal with the notion of "Styles"... but this is a bit complex for a simple editor, so I suggest you to just stick to the JEditorPane).
    Any of these three Components has a document model related to it. These document models can be of different types. For example, PlainDocument, StyledDocument, HTMLDocument, etc...
    A JTextArea can only have PlainDocument bound to it. These documents don't keep info about color, font, bold, and stuff for specific portions of text.They apply it to all content.
    JEditorPane can have PlainDocuments, HTMLDocuments and I think they can have StyledDocuments.
    To set bold to selected text you've got to do this :
            import javax.swing.text.*;
            int posStart = editorPane.getSelectionStart( );
            int posEnd =  editorPane.getSelectionEnd( );
            int selLength = posEnd - posStart;       
            MutableAttributeSet atr = new SimpleAttributeSet();
            StyleConstants.setBold(atr,true);
            StyledDocument doc = editorPane.getDocument();
            //Check out false in the following instruction
            // it means that any other attribute existing should
            // be kept if it has not be redefined in the attribute you are applying
            doc.setCharacterAttributes(posStart,selLength,atr,false);         That's it.. that's the way to do it.. the same principle applies for any other attribute,
    for example if you also wanted to change font you could have added the following :
            StyleConstants.setFontFamily(atr,"Arial");Alright, so know I'm going to give you the good adresses to learn stuff about Editors, here I go:
    * The Swing Connection Articles (hard to understand for a newbie but really helpful ):
    http://java.sun.com/products/jfc/tsc/articles/index.html (Check out the TextPackage Articles)
    * Manning Matthew Robinson and Pavel Vorobiev Swing book (it's all online for free)
    This is the absolute reference, step by step examples. Check out Chapter 20 : Constructing a
    Word Processor. (This is I guess the best stuff available online about constructing Text and HTML Editors in Java with Swing)
    http://www.spindoczine.com/sbe/

  • How to add Multiple XML Tags for a single column for an RDF

    Hi Gurus,
    I have Requirement in the Oracle D2k Report from which we are generating the xml tags.
    My Requirement is in a table i have 2 columns say A and B.
    i am able to generate three xml tags separately using the report builder by clicking on the column name and in the xml setting giving the xml tag.
    eg: table Acount contains 2 columns A and B with respective data
    A B
    QT 1
    QTS 0
    QTR 2
    i am able to general xml tags like this
    <ACount>
    <AStatus>QT</AStatus>
    <HeadCount>1</HeadCount>
    </ACount>
    <ACount>
    <AStatus>QTS</AStatus>
    <HeadCount>0</HeadCount>
    </ACount>
    my requiremnt for the xml tags is
    <ACount>
    <AStatusQT>1</AStatusQT>
    <AStatusQTS>0</AStatusQTS>
    </ACount>
    kindly help me out how to achieve this requirment in the rdf file mulitple xml tags.
    all your input are most valuable to me, thanks in advance
    Edited by: 909577 on Apr 9, 2012 3:10 PM

    I'm sorry for being so dense, but I'm not quite following, although what I've tried makes me think if I can follow you, it will work :)
    To answer your initial questions, you are correct with both your assumptions:
    1) detailType is the parameter that specificies YTD/Weekly, this is a "report defined" parameter that I am using to determine which Row Group to display (either YTD or Weekly)
    2) SchoolDaysActiveWeek is the parameter that is being set to either true or false -- this is a field in the cube that states whether that record is for the current week or not
    So in following your instructions, well that's the problem I'm not quite following :)
    1) When you say Delete the SchoolDaysActiveWeek parameter from the report only, do you mean to mark the parameter as Hidden?  If so, I've done this.
    2) I'm not quite sure where to use the statement you provided me.  You said to put it in the dataset, but I don't know which dataset.  I assume you mean the "main" dataset (as opposed to the hidden dataset that gets generated when you mark a field
    as a parameter).  If this is the case, the only place I could see that would allow you to use such a statement is in the Filter section of the properties.  I tried this, and it did not generate any errors, but it also kept my report groups from displaying
    -- it just showed a blank report, so I think it probably wasn't bringing back any rows to populate them with.
    I also tried going into the Expression section for the SchoolDaysActiveWeek parameter in the second screenshot and placing the statement there.  When I did this and ran the report, I would get the following error:
    The 'SchoolDaysActiveWeek' parameter is missing a value
    So what am I missing!? 
    Also, thanks for taking the time to respond!!

Maybe you are looking for

  • Sync applications problem with 3GS and new computer

    Hopefully someone can help me out. I am trying to sync my fiancee's 3GS to our new Dell laptop that has Windows 7. I had no problem syncing and updating my 3GS with the same computer last night, I updated to the 4.0 last night on my phone. I then tri

  • IPhoto '11 duplicates when editing in external editor

    What the topic says. iPhoto automatically creates a duplicate, that actually shows up as a duplicate in the library, when you choose to edit a photo in an external editor (such as Photoshop). It used to just replace the original, thus showing only th

  • My mac keeps freezing and showing the color wheel how can that be fixed

    my mac is soooo slow.  It is very frustrating.  Has been noticeable worse since downloading Lion.  Any suggestions

  • Document access via WAN in portal

    Hi, I have the following problem. I have installed portal with KM in place A and some users are in place B. Both places are connected via WAN (1Mbit/s). Users in place B have some documents stored in there LAN so they can access them relatively quick

  • Iphoto 6 not updating

    Hi,I have just installed an update from apple dvd.From os 10.4 to os 10.6.8.Everything except iphoto has updated.I am still running iphoto 6 .I have done software update online and it tells me that everything is upto date. Any ideas? Thanks