Check for existing XML element

Dear all,
I'm trying to write a simple script first checking to see whether an XML element exists, and then creating it if it doesn't. I've tried editing a piece of code that I used previously to do the same for paragraph styles, but apparently it's not that straightforward. Currently, all I get is the error "Cannot execute the script in target engine 'main'!" Without the checking, adding the XML element based on the search result works fine.
/* Find all instances of the word "Superscript" */
app.findTextPreferences.findWhat = "Superscript";
var mySuperscript = myDocument.findText(); // Save search result for future reference
/* See if an XML element named "Superscript" already exists, and create it if that's not the case; then add it to all instances of the word "Superscript" */
var myXMLElementSuper = myDocument.xmlElements.item("Superscript");
try {
var myName = myXMLElementSuper.name;
catch (myError){
    var myXMLElementSuper = myDocument.xmlElements.add({markupTag:"Superscript", xmlContent:mySuperscript[i]});}
Any assistance would be greatly appreciated!
Kind regards and thanks in advance,
Julian

Try this,
app.findTextPreferences=app.changeTextPreferences=null; 
app.findTextPreferences.findWhat = "Superscript"; 
var mySuperscript = app.activeDocument.findText();
for(var i=0; i< mySuperscript.length; i++)
    if(mySuperscript[i].associatedXMLElements[0].markupTag.name != "Superscript")
        app.activeDocument.xmlElements[0].xmlElements.add({markupTag:"Superscript", xmlContent:mySuperscript[i]}); 
app.findTextPreferences=app.changeTextPreferences=null; 
Vandy

Similar Messages

  • Rename or Tag Element for particular Xml Element.

    hi,
    How to rename or Tag Element for particular Xml Element using Java Script.
    eg)label to labels
    Thanks in advance
    Smile

    Hi,
           Thanks a lot Jeff...
            I'm doing a huge program with lot of tasks. While doing that,my mind didn't strike to check if the tag is not already exist, then only to create new tag...  Thanks for all of the indesigner experts for their replies...
    I used the following codes with ur idea.
                        var renamewith = textbox1.text;
                        try
                            alert(app.activeDocument.xmlTags.item(renamewith).name);
                            if(app.activeDocument.xmlTags.item(renamewith).name)
                               var testTag = app.activeDocument.xmlTags.item(renamewith);
                        catch(e)
                            var testTag = app.activeDocument.xmlTags.add({name: renamewith});
    With Regards,
    Vel.

  • Multi-level nested tables for repeatable XML Elements

    Hi there,
    Suppose we have a XML Schema „ASchema“ like this (XMLDB schema annotations are left out for simplicity):
    <xs:schema xmlns:xs=" .... " />
    <xs:element name=“A“>
         <xs:complexType>
              <xs:sequence>
                   <xs:element name=“B“ maxOccurs=“unbounded“/>
                        <xs:complexType>
                             <xs:sequence>
                                  <xs:element name = “C“ maxOccurs=“unbounded“/>
                             </xs:sequence>
                        </xs:complexType>
                   </xs:element>
              </xs:sequence>
         </xs:complexType>
    </xs:element>
    </xs:schema>
    After registering this schema in Oracle, I can define a table like this:
    CREATE TABLE ATable
    id NUMBER,
    doc XMLTYPE
    XMLTYPE COLUMN doc
    XMLSCHEMA “ASchema“ ELEMENT “A“
    VARARRAY doc.“XMLDATA“.“B“ STORE AS TABLE “BTable“
    ((PRIMARY KEY (NESTED_TABLE_ID, SYS_NC_ARRAY_INDEX$)) ORGANIZATION INDEX)
    This creates a nested table "BTable" within the table "ATable". So far so good, I can use this nested table to gain faster access on every possible subelement of Element B when I set an appropriate index.
    I now want to create another nested table for element “C“ like this:
    DROP TABLE ATable;
    CREATE TABLE ATable
    id NUMBER,
    doc XMLTYPE
    XMLTYPE COLUMN doc
    XMLSCHEMA “ASchema“ ELEMENT “A“
    VARARRAY doc.“XMLDATA“.“B“ STORE AS TABLE “BTable“
    ((PRIMARY KEY (NESTED_TABLE_ID, SYS_NC_ARRAY_INDEX$)) ORGANIZATION INDEX)
    VARARRAY doc.“XMLDATA“.“B“.“C“ STORE AS TABLE “CTable“
    ((PRIMARY KEY (NESTED_TABLE_ID, SYS_NC_ARRAY_INDEX$)) ORGANIZATION INDEX)
    But this statement fails with the error message something like „ ... no such attribute ... „
    And here's my question: is it possible to create nested tables for repeatable XML Elements that are subelements of other repeatable XML Elements ? And if so, how can I do it ?
    Thank you very much in advance
    Jan

    Found a (partial) solution myself:
    If you add the attribute xdb:storeVarrayAsTable="true" to the root element of the XML schema, Oracle XMLDB generates nested tables for all repeatable XML Elements while registering the XML schema.
    Unfortunately, the names of these nested tables are system-generated, hence it's a bit uncomfortable to set indices on them. You can find out the names of these nested tables as follows:
    select table_name, parent_table_name, parent_table_column from user_nested_tables;
    Further information on that subject is supplied in the following thread:
    Re: default tables for elements with maxoccurs > 1
    It would be nice if there was a way to name the generated nested tables via appropriate XMLDB schema annotations.
    regards
    Jan

  • Checking for existing Rollback Segments

    Hello you all,
    Is there a possibility to check for existing rollback segments within procedures?
    Thanks
    Hans

    Hello
    If you just want to be able to find out what rollback segments there are, you can query dba_rollback_segs, which will give you all sorts of info about rollback segments.
    Is that what you need or is it more involved?
    David

  • Hello, I have already bought FIFA 14 unlock pack.But now I've installed on my iPod and make check for existing purshase and it happen ''The Apple ID you entered couldn't be found or your password was incorrect.'' What that means?

    Please help me

    What do you mean by ""make check for existing purchase and it happens (error message)."
    Just what are yo doing when yo get that error message?

  • Imported XSLT cannot create attributes for generated XML element

    I have two xslts. One imports the other.
    The imported xslt creates XML elements with attributes and this XML is stored in a variable in the main stylesheet
    If I perform the transformation with JRE prior to 1.6.0.18 then all works fine
    If I use 1.6.0.18 or 1.6.0.19 then the attributes aren't added.
    If I add attributes in the main xslt it works fine or if I output the element directly instead of first storing it in a variable then it also works fine.
    Problem seems to be when you try to add attributes from an imported stylesheet and store the generated element in a variable.
    Below two stylesheets to illustrate :
    First MainStylesheet.xsl
    <?xml version="1.0" encoding="UTF-8"?>
    <!-- Copyright 1993-2005 Seagull Software Systems, Inc. -->
    <xsl:stylesheet
    version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:exsl="http://exslt.org/common"
    extension-element-prefixes="exsl"
    exclude-result-prefixes="xs">
    <xsl:output method="xml" version="1.0" encoding="utf-8" indent="yes" />
    <xsl:import href="innerstylesheet.xsl"/>
    <xsl:template match="/TestData">
    <xsl:variable name="generatedElementXml">
    <xsl:call-template name="generateElement">
    <xsl:with-param name="s">testValue</xsl:with-param>
    </xsl:call-template>
    </xsl:variable>
    <xsl:for-each select="exsl:node-set($generatedElementXml)">
    *** GeneratedElementXML {<xsl:text>
    </xsl:text><xsl:copy-of select="*"></xsl:copy-of>
    </xsl:for-each>
    </xsl:template>
    </xsl:stylesheet>Next innerstylesheet.xsl
    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet
    version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:exsl="http://exslt.org/common"
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    extension-element-prefixes="exsl" >
            <xsl:output method="xml" version="1.0" encoding="utf-8" indent="yes"/>
            <xsl:template name="generateElement">
                       <xsl:param name="s"/>
                    <TestElement testAttribute="$s" />
            </xsl:template>
    </xsl:stylesheet>The result output by jres before 1.6.0.18 is :
    <?xml version="1.0" encoding="UTF-8"?>
                   *** GeneratedElementXML {
              <TestElement xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" testAttribute="testValue"/>
                   }          The result output by jres since 1.6.0.18 is :
    <?xml version="1.0" encoding="UTF-8"?>
                   *** GeneratedElementXML {
              <TestElement xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
                   }          Note : the 'testAttribute' attribute is missing

    Have found the difference in the code
    In both JRE1.6.0_17 & JRE1.6.0_18, the class 'com.sun.org.apache.xalan.internal.xsltc.dom.AdaptiveResultTreeImpl' has the following method
    public void addUniqueAttribute(String qName, String value, int flags)
            throws SAXException
            addAttribute(qName, value);
        }In JRE1.6.0_17 the next method is
    public void addAttribute(String name, String value)
         if (_openElementName != null) {
             _attributes.add(name, value);
         else {
             BasisLibrary.runTimeError(BasisLibrary.STRAY_ATTRIBUTE_ERR, name);
        }In JRE1.6.0_18 the next method is
    public void addAttribute(String uri, String localName, String qname,
                String type, String value)
         if (_openElementName != null) {
             _attributes.addAttribute(uri, localName, qname, type, value);
         else {
             BasisLibrary.runTimeError(BasisLibrary.STRAY_ATTRIBUTE_ERR, qname);
        }Note - the addAttribute method has additional parameters in JRE1.6.0_18 but the call from addUniqueAttribute wasn't updated.
    So in JRE1.6.0_18 addUniqueAttribute actually invokes the following method in the base package com.sun.org.apache.xml.internal.serializer.EmptySerializer
    public void addAttribute(String name, String value)
            aMethodIsCalled();
    void aMethodIsCalled()
            // throw new RuntimeException(err);
            return;
        }and as you can see this does nothing. Hence the fact that the attribute isn't added.

  • How can I get the Attribute Value in the existing XML Elements-Reg.

    Dear All,<br /><br />  I have the InDesign Document with xml Based, now I want to get the XML Elements name and XML Attributes for each Elements, using SDK Concepts. <br /><br />Example:<br /><br /> <chapter>  chapter1 </chapter> id = "ch001"<br /> <sec> Section ....</sec> id ="se001"<br /> <para> para ....</para> id="pa001"<br /><br />How can I get the XMLElements & XML Attributes in the InDesign-XML Structure.<br /><br />Please  any one can suggest me....<br /><br />Thanks & Regards<br />T.R.Harihara SudhaN

    Dear Dirk
    Many Thanks for the Suggestions, Now I search and study the XML concepts. Meanwhile, I need your suggestions for further Development in SDK -XML concepts.
    I am using the SnippetRunner -SDK file, their given some XML based programmes. [Create XML Elements, Elements + Attributes, XML Comments] and etc...
    Hope U will help me to Develop the SDK- XML Concepts.
    Thanks & Regards
    T.R.Harihara SuduhaN

  • File Handling (Check for existing file)

    now my problems is that i need to have a code that upon a request checks for a file (in the home dir) and if the file exists reads the information and ouputs it. here is an example:
    check if file TEST.DATA exists?
    check approved TEST.DATA exists
    information outputed...
    if the file is missing i need to have an error message...
    PS. sorry if the question falls under "lame" but i am fairly new to java and i dont know the commands that well... thank you in advance!

    File.exists()
    Reading Text from a File
    Useful places to seek for information:
    - Java API documentation
    - The Java Tutorial
    - Code examples from Java developpers Almanac
    - Google
    - ...

  • Weblogic 7 checks for wellformed xmls

    Hello,
    I am having trouble deploying my applications with WLS 7.0. The error I am getting
    is that my web.xml is not well-formed, but I have double-checked everything and
    I think it is correct.
    I have read that weblogic 7.00 does not deploy an application which xmls are not
    well-formed (whereas earlier versions of weblogic would do so).
    My question is: against what dtds does WLS 7 check the web.xml, the weblogic.xml
    , etc.?
    I would think that it would check it against the dtd in the head of the xnl file,
    i.e., http://java.sun.com/dtd/web-app_2_3.dtd for the web.xml, is this correct?
    If this was true, what about intranet applications that are not connected to the
    Internet? could this be the reason?
    TIA
    Cristina Ceballos

    hi,
    i doubt your architecture.
    u r calling local bean from the client,which is not possible.
    your architecture should be as follows.
    jsp calls ejb(remote wrapper bean) which internally calls localbean.
    or
    jsp calls java which calls remote bean.
    for calling remote u can lookup as follows
    Object objref = initial.lookup("MoveMos");
    problem in your code its not able to narrow the home interface.
    try changing the architecture.
    if u have any problems further reply back
    thx,
    abdul.

  • Is there any tools can check for existed database ?

    hi all, is there any tools that can check for that existed database after inserted a database to Ms access??

    Then you'll open a connection and then do a Select from table to retrieve information. (and close afterwards)
    /Y 
    LabVIEW 8.2 - 2014
    "Only dead fish swim downstream" - "My life for Kudos!" - "Dumb people repeat old mistakes - smart ones create new ones."
    G# - Free award winning reference based OOP for LV

  • Popup to download firefox 4 timed out after install ran about a minute and now will not load or let me download FF 4 or remove FF3.6 (Message: checking for existing installation)

    I got a popup balloon to update to Firefox 4. I clicked it and after running the install for about a minute, it quit and I got a message saying it had timed out. It gave me the website to go to to manually install it. I downloaded the manual install for FF 4, but when I tried to run it, the Firefox Setup Wizard said it was "checking existing installation" and then brought up a window saying Firefox must be closed to run the install. Firefox was not open. I tried to open it and it won't open. I then tried to delete it in my "Add/Remove Programs" (Windows XP Home Edition). I got the same messages: that it was checking the existing installation and that I had to close all firefox programs before I could delete it. I'm out of ideas.

    I got a popup balloon to update to Firefox 4. I clicked it and after running the install for about a minute, it quit and I got a message saying it had timed out. It gave me the website to go to to manually install it. I downloaded the manual install for FF 4, but when I tried to run it, the Firefox Setup Wizard said it was "checking existing installation" and then brought up a window saying Firefox must be closed to run the install. Firefox was not open. I tried to open it and it won't open. I then tried to delete it in my "Add/Remove Programs" (Windows XP Home Edition). I got the same messages: that it was checking the existing installation and that I had to close all firefox programs before I could delete it. I'm out of ideas.

  • PA20/PA30 Green Check For Existing Infotypes

    Can anybody tell me how the green check mark shows up on the screen for existing infotypes when you do a PA20/PA30?  I have a request to try and make it show up on the TIME Infotypes, because currently it doesn't even when they are there.

    Hi Richard,
    The solution to your query is included in sap note no. 713327.
    Please apply it and you will solve your requirement.
    Kind regards,
    Rodrigo

  • Credit check for existing Verizon customer

    Hello!  I am looking for some assistance.  I recently received an email from BB about a 2500 point Reward Zone bonus for buying a new phone w/ a two year plan.  I am currently on my mother-in-law's family plan but due for an upgrade.  After going through all the checkout steps, I was met with a request for a credit check for my mother-in-law.  This makes little sense to me, as we have been Verizon customers for years and have a total of four accounts with them under this plan.  If we are longstanding customers with Verizon, why does Best Buy claim Verizon needs to do a credit check?  I know one wouldn't be necessary if we were to go to an authorized Verizon dealer for this purchase.  So how can BB claim the check isn't for themselves when Verizon already has no issue with the account's credit?
    I would love the bonus points but I'm not about to dent my mom-in-law's credit with a credit check.  It sours me on ever going through Best Buy for any mobile service in the future.  If Verizon is fine with the account and the current credit status, why does BB force one on us while claiming it's for a company that alreayd has no issue with the account holder's credit score?

    All credit checks are done through the carrier. Verizon does periodically request updated an credit report, even when performing an upgrade. This same process would take place no matter where you get your phone -- Best Buy, Verizon corporate stores, or other third-party dealers.
    Dan K. | Mobile Specialty Stores
    Any opinions expressed in this post are those of
    the author and do not represent Best Buy Co., Inc.

  • Moving an existing xml element into aTable

    Hi Everyone,
    After importing the xml I need to place or convert the xml elements into the table. Is there any way to do this by JS?
    Here is the sample Table xml elements....
    <table-wrap id="ch3_t1">
    <label>Table 3.1</label>
    <caption>
    <title>Anatomy and Classification of Major Hepatic Resections</title>
    </caption>
    <table>
    <thead>
    <tr>
    <th align="left" valign="top" colspan="5">Anatomic Classification</th>
    </tr>
    <tr>
    <th align="left" valign="top">Couinaud</th>
    <th align="left" valign="top" colspan="2">Goldsmith and Woodburne</th>
    <th align="left" valign="top">Brisbane</th>
    <th align="left" valign="top">Segments resected</th>
    </tr>
    </thead>
    <tbody>
    <tr>
    <td align="left" valign="top">Right hepatectomy</td>
    <td align="left" valign="top" colspan="2">Right hepatic lobectomy</td>
    <td align="left" valign="top">Right hemihepatectomy</td>
    <td align="left" valign="top">V, VI, VII, VIII</td>
    </tr>
    <tr>
    <td align="left" valign="top">Right lobectomy<sup>a</sup>
    </td>
    <td align="left" valign="top" colspan="2">Extended right hepatic lobectomy</td>
    <td align="left" valign="top">Right trisectionectomy</td>
    <td align="left" valign="top">IV,V,VI, VII, VIII<sup>b</sup>
    </td>
    </tr>
    <tr>
    <td align="left" valign="top">Left hepatectomy</td>
    <td align="left" valign="top" colspan="2">Left hepatic lobectomy</td>
    <td align="left" valign="top">Left hemihepatectomy</td>
    <td align="left" valign="top">II, III, IV</td>
    </tr>
    <tr>
    <td align="left" valign="top">Extended left hepatectomy<sup>a</sup>
    </td>
    <td align="left" valign="top" colspan="2">Extended left lobectomy</td>
    <td align="left" valign="top">Left lateral sectionectomy</td>
    <td align="left" valign="top">II, III, IV, V, VIII<sup>b</sup>
    </td>
    </tr>
    <tr>
    <td align="left" valign="top">Left lobectomy</td>
    <td align="left" valign="top" colspan="2">Left lateral segmentectomy</td>
    <td align="left" valign="top">Left trisectionectomy</td>
    <td align="left" valign="top">II, III</td>
    </tr>
    </tbody>
    </table>
    </table-wrap>
    Looking forward your replies... Your help will be thankful....

    You may want to look again, specifically section 20.11 Moving Oracle Enterprise Content Management to a Production System, Task 4.
    The same basic steps would apply to 10g, minus the WebLogic parts. (Also note that prior to 11g, what you are attempting is really a non-supported configuration. In 11g, Oracle at least gives this set of supported pointers.)

  • HOw to check for the Child Elements USing only SAX Parsr?

    HI Guyz,
    How to check whether there are any Child Elements in an XML file using ONLY SAX parser ??? I have a requirement of checking first whether there is any Child Elements exists for a Element or not and based on that I have to take certain actions. Can anyone suggest me How to do that ???
    Thanx
    KK

    Since SAX is event controlled, you wont know if there's a child element unless you actually bump into it with the Parser. You'll simply get another startElement event after your current one.
    /Tom

Maybe you are looking for

  • Unknown Error when I Logging and Transfer P2 Card files in FCP 6.0.6

    I have been trying for the past two week to Log and Transfer P2 files to my external hardrive using FCP 6.0.6 unsuccessfully. Originally I tried to Log and Transfer directly from the Panasonic HPX-170 in between my shooting. The first time it was a s

  • ITunes 7.0.1 OR iPod Nano 2G has actually scrambled my music files

    Recently I loaded several albums onto my new iPod nano. Upon playing some of the music I cam to find that two of my albums were altered; and not just in itunes. The actual files themselves have become a pastiche of samples from other .mp3/.m4a files.

  • Keynote 6.0

    I clicked "upgrade" for the new version of Keynote in the Apps Store.  Now it says "Installed", but it's still the old (5.3) version on my computer.  Now what?

  • 9.0.4.x vs 10.1.2

    We are preparing to migrate fron 9iASR2 to 10g. What is the difference between the R1 of 10g and R2? Is there a reason not to migrate directly to 10gR2?

  • Composition Environment trial - Process Composer

    I installed the trial version of Composition Environment available in SDN and the corresponding IDE. When I try to follow the example, and create a new project, Process Composer isn't available in NWDS. What do I have to do, to get BPM components?