Excluding xml in this script elements...

This script (Green4ever) Insert '\r' after the element:

var myDoc = app.activeDocument;
var inddRooElement = myDoc.xmlElements.item(0);
var xPathElements = inddRooElement.evaluateXPathExpression("//*");
var elementCount = xPathElements.length;
for(var eId=0; eId<elementCount; eId++){
    var thisXpathElement = xPathElements[eId];
    thisXpathElement.insertTextAsContent("\r", XMLElementPosition.AFTER_ELEMENT);
    }
alert("Done");

But I need some XML elements are excluded.
How I can exclude some Elements XML ?
How to make exclude all items who have in the tag " < p > "?

Thank you...

Try:

var xPathElements = inddRooElement.evaluateXPathExpression("//*[not(ancestor::p)]");

or, if you want to exclude p

var xPathElements = inddRooElement.evaluateXPathExpression("//*[not(ancestor-or-self::p)]");

Jeff

Tags: InDesign

Similar Questions

  • Please correct this script to call xml element

    Hi all

    How to fix this script for 'lev1sec1' calls 'H1' in the paragraph style, and "lev2sec1" must call "H2".

    Issue 1:

    This is the code: this works very well for xml file below.

    var myDocument = app.documents.item(0);
        var myPage = myDocument.pages.item(0);
      //Create a tag to style mapping.
      myDocument.xmlImportMaps.add(myDocument.xmlTags.item("heading_1"), myDocument.paragraphStyles.item("H1"));
      myDocument.xmlImportMaps.add(myDocument.xmlTags.item("heading_2"), myDocument.paragraphStyles.item("H2"));
      myDocument.xmlImportMaps.add(myDocument.xmlTags.item("para_1"), myDocument.paragraphStyles.item("TXF"));
      myDocument.xmlImportMaps.add(myDocument.xmlTags.item("body_text"), myDocument.paragraphStyles.item("TX"));
      //Map the XML tags to the defined styles.
      myDocument.mapXMLTagsToStyles();
    

    3.png

    2nd question:

    Another xml file has different coding as below, but its presentation as below, lev1 (H1) and lev2 (H2) all have two same < title > tag, how do I set '< id article = "ch01lev1sec1" > < title >' for H1, < id article = "ch01lev2sec1" > < title > H2. For your reference, I enclose below the snapshot.

    4.png

    2.png1.png

    Please help with this problem.

    by

    hasvi

    Hasvi,

    Try this.

    #include "glue code.jsx";
    var doc = app.activeDocument,
        ruleSet = new Array (new AddReturns);
    __processRuleSet(doc.xmlElements.item(0), ruleSet);
    function AddReturns()
    {
        this.name = "MapStyles";
        this.xpath = "//section[@id]";
        this.apply = function(element)
        {
            if(element.xmlAttributes.itemByName("id").value === 'ch01lev1sec1')
            {
                    element.applyParagraphStyle('H1')
                }
            if(element.xmlAttributes.itemByName("id").value === 'ch01lev2sec1')
            {
                    element.applyParagraphStyle('H2')
                }
            }
        }
    

    Kind regards

    Cognet

  • Speed Dial gives me an XML parsing error: no element found

    Have set up the Speed Dial and also set it as homepage. But when I then open Firefox, speed dial does not work and I get:
    XML Parsing Error: no element found
    Have retried reloading Speed Dial twice, and this happens every time. I am running Firefox 3.6.16.

    There is an extension conflict. See this article: blog of Speed Dial on this problem article

  • Root element is missing. System.Xml.XmlException: The root element is missing.

    Hello

    I have .NET 3.5 Web service hosted in my machine (Windows XP SP3) DEV .net 3.5 sp1... When I try to access the service form my

    client is the exception as below...

    Root element is missing. System.Xml.XmlException: The root element is missing.
    at System.Xml.XmlTextReaderImpl.Throw (Exception e)
    at System.Xml.XmlTextReaderImpl.ThrowWithoutLineInfo (String res)
    at System.Xml.XmlTextReaderImpl.ParseDocumentContent)
    at System.Xml.XmlTextReaderImpl.Read)
    to System.Xml.XmlTextReader.Read)
    at System.Xml.XmlReader.MoveToContent)
    at System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse (SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall)
    at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke (String methodName, Object [] parameters)

    Can any one opinion on this issue... Am I missing any software update...

    Thanks in advance...

    Kind regards

    Richard Starck M.

    Hi RAMANSELVA,

    Your question is more complex than what is generally answered in the Microsoft Answers forums. It is better suited for the IT audience Pro on MSDN. Please post your question in the MSDN forum.

    http://social.msdn.Microsoft.com/forums/en-us/netfxsetup/threads

  • Is it possible to create a new file using the XML via java Script?

    Hello everyone,

    Is it possible to create a new file using the XML via java Script

    • I have xml information that need to use for file name, size.
    • Based on xml file we can create a new file in InDesign with java script?
    • Kindly help me if anyone has an idea about this.

    I use InDesign CS4 on windows 7

    Sample file is attached below.

    Kind regards

    Siva

    <UpdateAd>
    <AdId>3403699</AdId>
    <Width type="mm">91,79</Width>
    <Height type="mm">80,00</Height>
    <ProductionCategory>4</ProductionCategory>
    <BookedCCIColors>sw</BookedCCIColors>
    <WorkFlowType>PDF</WorkFlowType>
    <CustomerNumber>652224</CustomerNumber>
    <CustName1>Erich Prang</CustName1>
    <Description/>
    <Description2>R</Description2>
    <UpdateIns>
    <Titel>RHZ</Titel>
    <Publication>B2</Publication>
    <RunDate>26-07-2011</RunDate>
    <Zone>H30</Zone>
    <KDDATEN>nein</KDDATEN>
    </UpdateIns>
    <WorkflowStep>IR</WorkflowStep>
    <Proof>No</Proof>
    </UpdateAd>
    
    

    xml.png

    Try this:

    var f =File.openDialog ();
    f.open('r');
    var xml = new XML(f.read());
    f.close();
    
    var myDocument = app.documents.add();
    myDocument.documentPreferences.pageHeight = xml..Height+"mm";
    myDocument.documentPreferences.pageWidth = xml..Width+"mm";
    var rect = myDocument.pages[0].rectangles,add();
    rect.geometricBounds = myDocument.pages[0].bounds;
    rect.strokeAlignment = StrokeAlignment.INSIDE_ALIGNMENT;
    rect.strokeColor = myDocument.swatches.item("Black");
    rect.strokeWeight = 1;
    myDocument.save(File(f.path + "/" + xml..AdId + ".indd"))
    

    Substances

  • What is this script?

    I recently picked up functions on the Web site of the Church (it was made by a guy across the continent before), there is a script in the head of <>and I don't know what he does.

    < script type = "text/JavaScript" >
    <!--
    function MM_goToURL() {//v3.0
    var i, args is MM_goToURL.arguments; document. MM_returnValue = false;
    for (i = 0; i <(args.length-1); I += 2) eval(args +".location='"+args[i+1]+"'");
    }
    ->
    < /script >

    Told me on another forum that this script is (MM = Macromedia) Dreamweaver and that "this function only manages a script element somewhere on the page that seeks to change the location of the current page." It was suggested that you can preview more here.
    Thus, the question. Nobody knows what kind of tag I would look to see if and when this script is used.
    Thanks for your help.

    This is the behavior of the goto url. Assistance from DW:
    "Go to the URL action opens a new page in the current window or in the specified frame. This action is useful to change the contents of two or more images with a single click. It can also be called in a calendar to go to a new page after a specified time interval. "

    If you want to see where it is called from, just get the code MM_goTOURL. If it is not called in the document, the function is no more necessary.

  • This script's bothering me: Script: chrome://tavgp/content/libs/include.js:595. How can I fix?

    When I run mozilla, mozilla does not open because this script.
    Script: chrome://tavgp/content/libs/include.js:595
    worried about the computer. After the computer asks me to stop this script, mozilla opens, but I have to wait for a long time.

    Help, please!

    Robert

    You must disable the "AVG Safe Search" so that that to go that it is related to "AVG FREE". See problematic Extensions, you don't want the extension is running, you must at least disable the extension. To avoid future problems, you must reinstall AVG Free without the link scanner component such as mentioned in the comments related to

    http://KB.mozillazine.org/Problematic_extensions
  • stop running this script?

    I get a message. "stop running this script? A script on this page slows down IE run slowly. If it continues to run, your computer may become unresponsive.

    How can I identify and remove the script?

    You can not. The script is on the Web page. If it gives you an option to stop it, do so.

  • In facebook, I get a error message box asking to stop "running this script. I have to click Yes or it will damage my computer. How can I stop this "SCRIPT" and what is it?

    I have an older browser. If I disable the compatibility mode, what would you do? Please, I beg you! What should I do to stop this script to run at facebook?

    Hi Jacqueline,.

    What browser do you use?

    If you turn off your Internet Explorer compatibility view, some Web sites may appear to be blank or will not display correctly.

    If you receive the error message in Internet Explorer, you can follow this link and check if the problem persists:

    How to troubleshoot the script errors in Internet Explorer on Windows computers?

    Hope the helps of information.

  • Message "stop running this script?

    I get a message asking me to "stop running this script" when I go to Yahoo to check my mail. I never received that message before today and I used Yahoo so busy Explorer for years. I disable the filter XSS, but that did nothing. I ran Internet Explorer troubleshooting, but has nothing to do. How can I get rid of this message, because it prevents me from my mail or do anything on Yahoo?

    It's a Yahoo! (Server/webmail) mail worldwide problem.
    See: Internet Explorer problem? and this thread, etc.

    Cordially.

  • Why I constantly get a message that says... "Stop running this script?"

    I constantly get a pop of message asking me if I want to "stop running this script"... a script on this page slows down Internet Explorer runs slowly. It happens on Facebook, no matter what I do, be it games or on the FB homepage.

    Follow this article http://support.microsoft.com/kb/175500

    Kind regards

  • We continue message "stop running this Script" and our computer is slow

    We are on facebook a lot and are now on the secure http, but it is slow and we still get a newsletter of windows that said Stop running this script? a script on this page slows down your web browser to run slowly

    Hello

     
     
    1 have you made changes to your computer recently?
    2. are you Internet Explorer to access the Internet?
    3. If so, what is the version of the operating system installed on your computer?
     
    I suggest you follow the steps, if you use
    Internet Explorer to access the Internet.
     
    Follow the steps in the link and check if that helps.
    Error message: "a script on this page slows down Internet Explorer runs slowly.
     
     
    I hope this helps.
  • Help me change this script

    I downloaded this script called "'export layers to files" (GitHub - jwa107/Photoshop-Export-Layers-to-Files-Fast: this script allows you to export individual layers as jpg /... ) " and it works as it should. However, I would like to delete the 'finished' dialog popup box that shows after each use. Just remove the script code and if so what?

    [Proposed by the Mod Forum scripts Photoshop]

    Looks like you also comment out the line 268 as well.

  • Cleaning of the appearance of this script?

    Hello I had a ton of help here for this script. I've made a few changes and was wondering if it was possible to clean underside is the image and the Script so far. I would like the script to look like the lower part of the table in this photo.  The Commander of the top edge of the page is what is really at work right now.  Any help would be greatly appreciated.

    Screen Shot 2016-05-31 at 4.45.13 PM.png

    Here's the Script.

       function doTextFrameOnPageOne()  
        
     {  
     // Name of the Text Frame The Save information is in.
        var myBlendingSettings = { blendMode : BlendMode.OVERLAY };  
        var myTransparencySettings = { blendingSettings : myBlendingSettings };   
        var doc, tf, tvINFO, ip;  
            doc = app.activeDocument;  
    // TEXT FRAME PROPERTIES        
            tf = doc.pages[0].textFrames.add({ fillColor :"Yellow", fillTint: 20, transparencySettings : myTransparencySettings, geometricBounds: ['-.75','-4.45in','1.5in','-.75in'] });
    
    // Text frame information
            ip = tf.insertionPoints;
            ip[-1].contents = "Document:"+"\t "+ doc.name  +'\r'; 
            ip[-1].contents = "User Name:" +"\t"+ getAppUserName() +'\r';
            ip[-1].contents = "Computer Name:" +"\t"+ getLogInUserName()+'\r';
            tvINFO = ip[-1].textVariableInstances.add(LocationOptions.AFTER, ip[-1]);  
            "Date Modified:" +'\t'; tvINFO.associatedTextVariable = doc.textVariables.itemByName("Modification Date");  
            ip[-1].contents = '\r';
            tvINFO = ip[-1].textVariableInstances.add(LocationOptions.AFTER, ip[-1]);  
            tvINFO.associatedTextVariable = doc.textVariables.itemByName("Output Date");  
            ip[-1].contents = '\r';  
            tvINFO = ip[-1].textVariableInstances.add(LocationOptions.AFTER, ip[-1]);  
            tvINFO.associatedTextVariable = "Date Created:" +'\t'; doc.textVariables.itemByName("Creation Date");  
      
     // Change Properties of Text Frame.:                  }  
    

    Thank you

    Alain bombaert

    It was a question essentially about the creation of a table with ExtendScript for InDesign.

    Basically, you have two options here:

    [A] convert the text in your block of text in a table

    [B] create a new table and assign the content via the content of the table property

    [A] would essentially work for you.

    But as I can see from your first screenshot that this would not work as expected, if you are remodeling your current in a table content, because you are missing the required content of a column for some lines. Of more deviding tabs. If you provide, you can use the following code:

    tf.parentStory.texts[0].convertToTable("\t","\r");
    

    [B] would cooperate with the result of your functions and methods and the necessary channels for column one and two stored in one or two paintings.

    Example:

    var columnOneContentsArray =
    [
         "Document:" ,
         "User Name:",
         "Output Date:"
    ];
    
    var columnTwoContentsArray =
    [
         "USE FOR TEST SCRIPTS.indd" ,
         "Chris Bishop" ,
         "" // Not really necessary to use an empty string, but could be used to indicate, that this cell will be empty for now.
    ];
    
    var doc = app.documents.add();
    var tf = doc.textFrames.add({geometricBounds : [0,0,"100mm","100mm"]});
    var myTable = tf.texts[0].tables.add
    (
         {
              bodyRowCount : 3 , // You could use a larger number here, even if your contents array uses less entries.
              columnCount : 2 
    
              // Use other property/value pairs to define the width of the table, stroke weights, fill color etc.pp.
              // ...
         }
    );
    
    myTable.columns[0].contents = columnOneContentsArray;
    myTable.columns[1].contents = columnTwoContentsArray;
    

    In your case you leave the content of your text variables in the columnTwoContentsArray and replace their contents with an empty string "" maybe.

    Later, after creating the table, insert you the text variable in the right cell using the first insertion point of the cell.

    var cell3OfColumn2insertionPoint1 = myTable.columns[1].cells[2].insertionPoints[0];
    var tvINFO = cell3OfColumn2insertionPoint1.textVariableInstances.add(LocationOptions.AFTER, cell3OfColumn2insertionPoint1);
    tvINFO.associatedTextVariable = doc.textVariables.itemByName("Output Date");
    

    Warning: Check, if your text variable already exists in your document.

    If so, use the existing one. If not, create a new.

    Note: I didn't test the extract with the text above variable.

    BTW. : this thread should go to the InDesign Scripting forum.

    Scripting InDesign

    Uwe

  • Is it possible to modify this script to be reusable in a function?

    Hello

    I have this script inside a load of buttons (currently 16 individual buttons)

    They all have a different value and increment them positively and some negatively, they are + - buttons

    Here's the Script:

    var fldTI1 = this.getField ("20mmLeft");

    If (isNaN (fldTI1.value)) {}

    fldTI1.value = 0;

    }

    else {}

    fldTI1.value += 1;

    this.getField("LeftAddOnTotal").value += 20;

    }

    I wonder if I can do this more universal so that I don't have to write it in a function and call that function?

    I know that I'll probably have to write 2 functions for each value (15, 20, 35 and 50), one for the positive growth and the other for the negative increment.

    I was thinking something in the sense of the use of var fldT1 = this.getField (event.target.name); or something like that so that the var takes the name where the function was called?

    I tried to look in the syntax event.target and it does but I can't find an explanation clear about what it actually does.

    Any help and suggestions would be greatly appreciated.

    Thank you in advance!

    In general, I have to debug a problem like this, I would add the following line at the top of the function:

    app.alert("addOnValues: " + name + " " + name2 + " " + op + " " + amount);
    

    This will display all the parameters passed to the function and will show you that the service has got actually called. Alternatively, you can use the JavaScript debugger and set a breakpoint on the first line of this function and simple then the code.

    However, in this case, I can tell you what the problem is (the first time that I looked at your code, I only had that my cell phone, now that I'm working on the computer, it is easier to see what's going on): if/else if construct you use has the same conditions several times:

    if (op == "inc") {
      // ...
    }
    else if (op == "inc") {
      // ...
    }
    

    In an if/else if/else construction, only the first matching condition will be executed. After that, the shell passes at the end of the construction and running the following command. You will need to create if statements at two levels:

    if (op == "inc") {
        if (isNaN(fldName.value)) {
          // ...
        }
       else {
         // ...
       }
    }
    else if (op == "dec") {
       if (isNaN(fldName.value)) {
         // ...
       }
      else {
         // ...
      }
    }
    else {
         // ...
    }
    

    You can simplify this a little more because you know that the 'isNaN' case action is always the same, so you can use this:

    if (isNaN(fldName.value)) {
    }
    else if (op == "inc") {
    }
    else if (op == "dec") {
    }
    else {
    }
    

    Once again, it is quite normal JavaScript and has nothing to do with the implementation of Acrobat JavaScript. You can read on the basis of the JavaScript syntax.

Maybe you are looking for