DOM pointers?

Hello -
I am beginning to use DOM and XPath in applications and am curious concerning the implementations. When evaluating an XPath and returning a NODE or NODESET, will the results be references to the original DOM elements or will copies be made simply containing the node types?
I ask because it would occur to me that if the types are actually references, then parent axes could be evaluated. At the moment, i'm seeing that a context is created that begins with a node/set which prevents parent/ancestor paths. This would suggest to me that the node/list is a copy and not a reference, but i wanted to confirm.
Thanks,
Isaac

Seems to me it wouldn't be hard to write a bit of code to answer this question. Modify the node returned by XPath and see if that modifies the node in the original DOM or not.

Similar Messages

  • How to Parse a string into an XML DOM ?

    Hi,
    I want to parse a String into an XML DOM. Not able to locate any parser which supports that. Any pointers to this?

    Download Xerces from xml.apache.org. Place the relevant JAR's on your classpath. Here is sample code to get a DOM document reference.
    - Saish
    public final class DomParser extends Object {
         // Class Variables //
         private static final DocumentBuilder builder;
         private static final String JAXP_SCHEMA_LANGUAGE =
             "http://java.sun.com/xml/jaxp/properties/schemaLanguage";
         /** W3C schema definitions */
         private static final String W3C_XML_SCHEMA =
             "http://www.w3.org/2001/XMLSchema";
         // Constructors //
         static {
              try {
                   DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
                   factory.setNamespaceAware(true);
                   factory.setValidating(true);
                   factory.setAttribute(JAXP_SCHEMA_LANGUAGE, W3C_XML_SCHEMA);
                   builder = factory.newDocumentBuilder();
                   builder.setErrorHandler(new ErrorHandler() {
                       public void warning(SAXParseException e) throws SAXException {
                           System.err.println("[warning] "+e.getMessage());
                       public void error(SAXParseException e) throws SAXException {
                           System.err.println("[error] "+e.getMessage());
                       public void fatalError(SAXParseException e) throws SAXException {
                           System.err.println("[fatal error] "+e.getMessage());
                           throw new XmlParsingError("Fatal validation error", e);
              catch (ParserConfigurationException fatal) {
                   throw new ConfigurationError("Unable to create XML DOM document parser", fatal);
              catch (FactoryConfigurationError fatal) {
                   throw new ConfigurationError("Unable to create XML DOM document factory", fatal);
         private DomParser() {
              super();
         // Public Methods //
         public static final Document newDocument() {
              return builder.newDocument();
         public static final Document parseDocument(final InputStream in) {
              try {
                   return builder.parse(in);
              catch (SAXException e) {
                   throw new XmlParsingError("SAX exception during parsing.  Document is not well-formed or contains " +
                        "illegal characters", e);
              catch (IOException e) {
                   throw new XmlParsingError("Encountered I/O exception during parsing", e);
    }- Saish

  • Adding attachments to xml dom generated documents

    Hello All,
    I am trying to add an attachment to a DOM generated XML document, does anyone have any idea as to how I amy be able to do this.

    Hi
    Happen to see your posting. Did you get any response for your question. I have a similar requirement. If you have any pointers, please let me know. Thanks for your help in advance.
    Regards
    Sri

  • XML validation using XDK DOM/SAX Parser

    Hello,
    I am trying to validate xml against xsd using SAX/DOM parser, both the files are stored as CLOB column in the database. I have the requirement to report all the validation errors and based on some helpful advice/code from the earlier posts in this forum, I have used the following code to validate and report the errors.
    The code works fine but for large files it never goes beyond a certain number of errors i.e. getNumMessages() (XMLParseException) never returns value greater than 100 and thus limits the output of the validation errors. Any pointers to suggest change in code or an alternative will be extremely helpful.
    Datebase Version : Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
    CREATE OR REPLACE AND RESOLVE JAVA SOURCE NAMED as package <package name>;
    import java.net.*;
    import java.io.*;
    import java.util.*;
    import java.sql.SQLException;
    import oracle.sql.CLOB;
    import oracle.xml.parser.schema.*;
    import oracle.xml.parser.v2.*;
    import org.w3c.dom.*;
    public class XMLSchemaVal
    public static String validate(CLOB xmlDoc, CLOB xsdDoc)
    throws Exception
    //Build Schema Object
    XSDBuilder builder = new XSDBuilder();
    Reader xsdInUnicodeFormat = xsdDoc.getCharacterStream();
    XMLSchema schemadoc = (XMLSchema)builder.build(xsdInUnicodeFormat, null);
    //Build XML Object
    Reader xmlInUnicodeFormat = xmlDoc.getCharacterStream();
    // Genereate the SAX
    SAXParser saxparser_doc = new SAXParser();
    // Set Schema Object for Validation
    saxparser_doc.setXMLSchema(schemadoc);
    saxparser_doc.setValidationMode(XMLParser.SCHEMA_VALIDATION);
    saxparser_doc.setPreserveWhitespace (true);
    String returnValue;
    try {
    saxparser_doc.parse (xmlInUnicodeFormat);
    returnValue = "The input XML parsed without errors.\n";
    catch (XMLParseException se) {
    returnValue = "Parser Exception: ";
    for (int i=0 ; i < se.getNumMessages(); i++)
    returnValue += "<LN: " + se.getLineNumber(i) + ">: " + se.getMessage(i);
    //returnValue = "Parser Exception: " + se.getNumMessages();
    catch (Exception e) {
    returnValue = "NonParserException: " + e.getMessage();
    return returnValue;
    Function to call the above utility from PL/SQL
    CREATE OR REPLACE FUNCTION F_XMLSCHEMAVALIDATION (P_XML IN clob ,P_XSD IN clob) RETURN VARCHAR2 IS
    LANGUAGE JAVA NAME XMLSchemaVal.validate(oracle.sql.CLOB,oracle.sql.CLOB) return java.lang.String';
    Thanks.

    I have the same question. I have an external DTD. I wish to parse an xml file using XMLParser.xmlparse. If I first call XMLParser.xmlparseDTD and then call xmlparse with the XML_FLAG_VALIDATE will the xml automatically be validated against the previously parsed DTD? There is no DOCTYPE declaration in the xml file.
    The demo code on OTN for Java is great but has no relation to the code you would use in C++ (no set functions in C++).

  • XML Validation using XDK SAX/DOM Parser

    Hello,
    I am trying to validate xml against xsd using SAX/DOM parser, both the files are stored as CLOB column in the database. I have the requirement to report all the validation errors and based on some helpful advice/code from the earlier posts in this forum, I have used the following code to validate and report the errors.
    The code works fine but for large files it never goes beyond a certain number of errors i.e. getNumMessages() (XMLParseException) never returns value greater than 100 and thus limits the output of the validation errors. Any pointers to suggest change in code or an alternative will be extremely helpful.
    Datebase Version : Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
    CREATE OR REPLACE AND RESOLVE JAVA SOURCE NAMED <> as package <package name>;
    import java.net.*;
    import java.io.*;
    import java.util.*;
    import java.sql.SQLException;
    import oracle.sql.CLOB;
    import oracle.xml.parser.schema.*;
    import oracle.xml.parser.v2.*;
    import org.w3c.dom.*;
    public class XMLSchemaVal
    public static String validate(CLOB xmlDoc, CLOB xsdDoc)
    throws Exception
    //Build Schema Object
    XSDBuilder builder = new XSDBuilder();
    Reader xsdInUnicodeFormat = xsdDoc.getCharacterStream();
    XMLSchema schemadoc = (XMLSchema)builder.build(xsdInUnicodeFormat, null);
    //Build XML Object
    Reader xmlInUnicodeFormat = xmlDoc.getCharacterStream();
    // Genereate the SAX
    SAXParser saxparser_doc = new SAXParser();
    // Set Schema Object for Validation
    saxparser_doc.setXMLSchema(schemadoc);
    saxparser_doc.setValidationMode(XMLParser.SCHEMA_VALIDATION);
    saxparser_doc.setPreserveWhitespace (true);
    String returnValue;
    try {
    saxparser_doc.parse (xmlInUnicodeFormat);
    returnValue = "The input XML parsed without errors.\n";
    catch (XMLParseException se) {
    returnValue = "Parser Exception: ";
    for (int i=0 ; i < se.getNumMessages(); i++)
    returnValue += "<LN: " + se.getLineNumber(i) + ">: " + se.getMessage(i);
    //returnValue = "Parser Exception: " + se.getNumMessages();
    catch (Exception e) {
    returnValue = "NonParserException: " + e.getMessage();
    return returnValue;
    Function to call the above utility from PL/SQL
    CREATE OR REPLACE FUNCTION F_XMLSCHEMAVALIDATION (P_XML IN clob ,P_XSD IN clob) RETURN VARCHAR2 IS
    LANGUAGE JAVA NAME XMLSchemaVal.validate(oracle.sql.CLOB,oracle.sql.CLOB) return java.lang.String';
    Thanks.

    Got the answer !!!
    NetBeans it self support generation of dtd file based on XML file.
    Open XML file and right click on the code block. Select option to generate dtd file.
    This is the drtd file it has generated..
    <?xml version='1.0' encoding='UTF-8'?>
    <!--- Put your DTDDoc comment here. -->
    <!ELEMENT book (person)*>
    <!--- Put your DTDDoc comment here. -->
    <!ELEMENT person (age|last|first)*>
    <!--- Put your DTDDoc comment here. -->
    <!ELEMENT first (#PCDATA)>
    <!--- Put your DTDDoc comment here. -->
    <!ELEMENT last (#PCDATA)>
    <!--- Put your DTDDoc comment here. -->
    <!ELEMENT age (#PCDATA)>

  • InDesign DOM Redesign and Redevelopment. I beg of you.

    The architecture of InDesign's Document-object Model handling has always perplexed me.  What should be a simple, straight-forward hierarchy of parent-to-child cascading style control is instead a haphazard peer-to-peer asynchronous spaghettibowl—a wonderful tribute to Pastafarians worldwide, yes, but hardly a good-working model for production of publications.
    I understand that when InDesign was being developed, Adobe did not yet hold a marketplace stronghold against competitors like Quark Xpress, and a seamless user experience between applications was key to get people to switch from one to the other. But it seems by doing so, Adobe shot itself in the developmental foot. Either that or there was simply no master plan for an overall framework for document object modelling.
    It's because of this that I really propose Adobe come up with a new structure. But how to do it without bricking the many tens of thousands of *.indd files out there? How to transition without destroying what's already been built? It's much like the 710 freeway in South Pasadena: finishing a simple gap of highway that would enable the entire system to flow better would essentially have to destroy an entire community of homes established over 50 years. Yet without it, things are a mess. InDesign 5 files are already incompatible with previous files, so I don't see too much harm in bricking them again.
    To illustrate my point, and the urgency, let me bring up the issue of Master Text Frames.  Anyone who's been using InDesign since the turn of the century has always seen the 'Master Text Frame' option on the 'New Document' window, hanging there pointlessly like a coccyx.  The reason for its existance has been the subject of much debate by several critiques ranging from independent design journalists to Lynda tutorial videos. Even though you can perform the same function by simply creating a text autoflow on a master page, it's still there as an option. And, as far as I know, it's an option impossible to toggle it any other menu-based means once the document has been created. This demonstrates that the feature's original purpose (as well-intended as it might have been originally) has been deprecated in the scheme of a bigger picture that's developed since then. We now have book files, template files, multiple masters, XML support, etc, etc... InDesign's original concept was all laid out during a period in history where we were transitioning out of the "Windows 98" peer-to-peer mindset of the 90's before returning to the time-tested server-client system. It's just better than peer-to-peer for not only internal networking but design structure.
    If that doesn't convince you, let me ask a question: Suppose I wanted to apply a template file (or better yet, elements of one) into an existing InDesign document? Sounds crazy I know, but we do this all the time in the web design world. So imagine if instead of master pages being embedded within documents, they were actually external template files like *.css, with stylesheets and scripts built into them? And like web structures, imagine that they controlled things from a top-down hierarchy to all the styles in all child documents of all book files?
    ie:
    indt > indb > indd.
    Simple.
    Master object/paragraph/character styles and libraries (and any other attribute you can think of) would be defined in the master document templates. From there. In book file, you would choose which template masters you wish to be associated with that book, and this selection of templates would carry down to the connected child documents. Finally, the child documents would inheirit these styles or could have their own embedded styles which would override the master styles, if desired.
    Now that I think of it, with this structure, indd files themselves would not even need to be touched for those people who don't want/need whole books. So mabye bricking things is unecessary.
    Compared to the peer-to-peer chicken-or-the-egg manual syncroninzation scheme in the indb pallete, it would be a simple automatic system ensuring uniformity among all involved documents in the book! And these template files, since external, could be used for many book files, automatically updating all of them. And we would never have to deal with the dreaded "UGH! Why is this style folder resyncing itself in a different order, and why did that style reappear when I just erased it!?" syndrome forevermore.
    InCopy could really become a truly useful application if done this way rather than a cheaper watered-down version of InDesign for editors. You could have a good chain of command between designer, editor, and typesetter. And it would be one step closer to seamless integration between print and web. If a better DOM manages to be produced, I have a feeling InCopy is going to go by the wayside, much like ImageReady.
    So yes, I urge that a serious redesigning and redevelopment of InDesign's style / object hierarchy be looked at, for the sake of humanity!  I'm sure I'm not the first one who has thought of this. It just takes an executive decision somewhere in San Jose. Here's hoping. Cheers.

    I think you misunderstand what a Book (.indb) file is. It's a collection of documents. It's not based on any template and it has no  attributes to speak of other than a list of pointers to the component documents and a record of pagination (maybe).
    Yes, I noted that.. the indb books wouldn't hold the styles within them. It would only pass them from template to document collections.
    Styles, swatches, master pages and pagination can be synchronized across the book, or not, as you decide.
    Yes. That wouldn't be interfered with. You can still embed styles within documents, or have them passed down from templates. Like I said, what I'm proposing is only a way to feed styles top-down from templates. The way things work now, a template disconnects from the document the moment you load it. I'm saying it should retain its connection as a master page.
    What I'm really proposing is the disengaging of embedded master pages and allow links for external master pages. Might as well make those the templates since we already have them.

  • Reimporting exported XML using DOM

    Hi,
    I'm trying to set up an import/export for a data structure, 'SimpleNode' created by a JavaCC parser for classical propositional logic.
    SimpleNode implements Node, and have the following attributes
    protected SimpleNode parent;
    protected SimpleNode[] children;
    protected int id;
    protected LogicParser parser;
    protected String label;
    ...So nothing too special there.
    A simple representation of the sentence
    a OR (b AND c) IMPLIES NOT(D)
    "a | (b & c) => !d"
    Is represented as a tree with in the following manner
    Root
    Imp
      Or
       Atom a
       And
        Atom b
        Atom c
      Not
       Atom dWhich is all fine.
    I've written something to export to an XML structure which gives the following output for the above sentence
    <IMPLIES>
      <NOT>
        <TRUE/>
      </NOT>
      <IMPLIES>
        <OR>
          <ATOM>a</ATOM>
          <ATOM>b</ATOM>
        </OR>
        <NOT>
          <ATOM>c</ATOM>
        </NOT>
      </IMPLIES>
    </IMPLIES>Which again, seems fine.
    The problem is then when I'm trying to reimport the XML and create a SimpleNode from it.
    Using the following code
         public static void main(String[] args) {
              // if (args.length <= 0) {
              // System.out.println("Usage: java DOMCommentReader URL");
              // return;
              String url = "propLogic.xml";
              try {
                   DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
                   DocumentBuilder parser = factory.newDocumentBuilder();
                   // Check for the traversal module
                   DOMImplementation impl = parser.getDOMImplementation();
                   if (!impl.hasFeature("traversal", "2.0")) {
                        System.out.println("A DOM implementation that supports traversal is required.");
                        return;
                   // Read the document
                   Document doc = parser.parse(url);
                   // Create the TreeWalker
                   DocumentTraversal traversable = (DocumentTraversal) doc;
                   // Taken from
                   // http://www.oreilly.com/catalog/jenut2/chapter/ch19.html
                   NodeFilter filter = new NodeFilter() {
                        public short acceptNode(Node n) {
                             if (n.getNodeType() == Node.TEXT_NODE) {
                                  // Use trim() to strip off leading and trailing space.
                                  // If nothing is left, then reject the node
                                  if (((Text) n).getData().trim().length() == 0)
                                       return NodeFilter.FILTER_REJECT;
                                  // if (n.getParentNode().getNodeName() != "ATOM")
                                  // return NodeFilter.FILTER_REJECT;
                             return NodeFilter.FILTER_ACCEPT;
                   int whatToShow = (NodeFilter.SHOW_ELEMENT + NodeFilter.SHOW_TEXT);
                   TreeWalker iterator = traversable.createTreeWalker(doc, whatToShow, filter, true);
                   printElements(iterator, 0);
              } catch (SAXException e) {
                   System.out.println(e);
                   System.out.println(url + " is not well-formed.");
              } catch (IOException e) {
                   System.out.println("Due to an IOException, the parser could not check " + url);
              } catch (FactoryConfigurationError e) {
                   System.out.println("Could not locate a factory class");
              } catch (ParserConfigurationException e) {
                   System.out.println("Could not locate a JAXP parser");
         public static void printElements(TreeWalker iterator, int depth) {
              Node n = iterator.getCurrentNode();
              n.normalize();
              String indent = new String();
              for (int i = 0; i < depth; i++) {
                   indent += "  ";
              depth++;
              System.out.print(indent + n.getNodeName() + " " + n.getNodeValue());
    //          if (n.getParentNode() != null)
    //               System.out.print(" (parent is " + n.getParentNode().getNodeName() + ")");
              System.out.println();
              for (Node child = iterator.firstChild(); child != null; child = iterator.nextSibling()) {
                   printElements(iterator, depth);
              iterator.setCurrentNode(n);
         }I can get a correct looking representation of the structure
    #document null
      IMPLIES null
        NOT null
          TRUE null
        IMPLIES null
          OR null
            ATOM null
              #text a
            ATOM null
              #text b
          NOT null
            ATOM null
              #text cBut I'm having trouble using the Iterator to create SimpleNodes from the Nodes
    All a SimpleNode needs is a type (an integer representing whether the operator is AND, OR, NOT, IMPLIES etc)
    and a label, which can be null or in the case of an ATOM will have the atom name, "a", "b", "c" etc.
    A SimpleNode is easily created with the constructor
    SimpleNode foo = new SimpleNode(type);
    foo.setLabel("a");
    and adding a child by
    foo.jjtAddChild(SimpleNode n, int i)
    where i is the number of the child.
    Hopefully I've not rambled too much and it makes sense.
    If anyone can give me any pointers or some code/pseudocode to pick through then it'd be much appreciated.
    Duncan

    No bother, tweaked the printElements to fix.

  • [AS CS5.5] Bad Perfomance: sequentially using DOM to get references

    Hi guys,
    The issue
    I'm having terrible performance problems when using a complex script I wrote.
    The script
    I need to make some special comparisons between found text and the texts in that page.
    My script is written in Flash Builder 4, using the CS_SDK (without Extension Builder)
    In short, my script has a class that performs the following tasks:
    1. Finds texts that meet some criteria (by using Document.findText() method) and stores the Array of texts result in an array.
    2. Traverses the Array of found texts and, for each one of them:
    a. Finds a reference to the page where that text is. Something like (within a for loop, with iFoundText as the indexing var):
    var currentParentPage     :Page     =
         foundText[iFoundText].parentStory.textContainers[0].parentPage;
    b. Finds all the page items in that page. The code goes something like this:
    var myPageItems      :Object     =
         currentParentPage.allPageItems;
    c. If the PageItem is a TextFrame, then make the 'special comparison', word by word.
    if (currentPageItem is TextFrame)
              var allTheWords     :Words =
                   currentPageItem.words
              for (var iWord:int = 0 ; iWord < allTheWords.length ; iWord++)
                   //Code to perform comparison and related operations...
    It seems to work OK, when allowing to perform the script for he first three occurrences (although very slow, say some 12 seconds for this).
    So, what's the problem?
    What happens when I run it with more load:
    When I run the script for all the occurrences (I know that the number is around 100), the application halts, an stops responding. After 10 min it doesn't work anymore.
    What the documentation says:
    I found a document called "FEATURE DEVELOPMENT WITH SCRIPTING - Adobe CS5" (link), where it gives this recommendation:
    Performance techniques
    Minimize access to InDesign DOM
    Querying the InDesign DOM may be the main performance bottleneck for your script. A considerable amount of time typically is spent resolving object references, because InDesign does not hand out pointers to objects but rather uses references that need to be resolved every time they are used. Here are some techniques to alleviate this problem:
    z Reduce the number of calls to the scripting DOM.
    z Store and reuse resolved references in variables wherever possible.
    z Use everyItem() to fetch and cache data of a collection object all at once, instead of querying the properties with separate calls.
    But I don't know how to not query InDesign's DOM every time...
    So. I understand that calling InDesign's DOM is bad for the script's performance, but I really don't know how could I avoid querying it for getting references to parent objects, or any other item.
    I have two questions
    1. If I have a variable stored in my AS script, for example:
    var anyTextItem:com.adobe.indesign.Text
    When I call a property or a method of that variable... Am I querying InDesign's DOM? (in other words, the variables' content is passed as a reference?)
    2. How do I query the DOM less times?
    For example:
    Problem: I constantly need to know what's the parent page of a found text, and then get the array of page items, and then, the array of words of every page item that is a textframe.
    How could I query the DOM once and then play with the stored variables instead of repetitively querying the DOM?
    Because, even if I have the variable stored, say "anyTextItem:Text", and I also have all the document's TextFrames stored in other variable (say "var allTextFrames:TextFrames"), I would still need to call "anyTextItem.parentTextFrame" to get a reference to the containing textFrame, and that would mean "querying InDesign's DOM".
    I would appreciate if anybody understands how to solve this.
    Thanks you, guys !

    Harbs,
    Thank you very much for your answer. You're very knowledgeable about InDesign DOM.
    Your message gives me a better understanding of how objects are managed between a scripting environment and the DOM. I still have some questions, though...
    b.
    I will change the call to 'allPageItems' to 'page.textFrames.everyItem().getElements()'. It makes much more sense.
    Now, quick question:
    What do you use 'getElements()' for?
    What's the diference between calling 'page.textFrames.everyItem().getElements()' and 'page.textFrames.everyItem()'?
    c.
    OK. I kinda got it. But, I have questions here too.
    For me, it's been quite tricky to understand indexes and references for InDesign DOM objects.
    Let's say that I have stored a Story's words object in my script. Something like:
    var currentWords     :Words = currentStory.words;
    And then, I go through a TextFrame that contains part of that Story, and find one word that meets my criteria. So I get:
    var foundWord        :Word = (... Somehow I got a reference to this ...);
    Is it there a way to easily find that word (by index) in the 'currentWords' object? (maybe using index or id...) The problem is that I've found that sometimes the indexes don't match (i. e. if I call "foundWord.index", its index can be way larger than the parentStory.words.length, for example, I got foundWord.index=942, whereas foundWord.parentStory.length=742).
    And, as a consequence, I'm using long workarounds to find the word within that collection (and I guess you'd scold me for this one; now I think that might be a serious performance killer, because I'm reconstructing the 'words' collection over and over again :S)
    Thanks again to both of you (@Harbs and @Andrés), you've been very kind and helpful.

  • Difference between DOM and SAX

    Difference between DOM and SAX

    a sax parser is event driven meaning it processes the xml as it sees it and then forgets about it.
    you have to implement what you want the parser to do wants it reaches a certain event
    dom on the other hand keeps the whole structure of the message in memory as a tree.
    so there are strengths and weaknesses in both.
    you have to evaluate what you need

  • Java-pointers

    difference between null and void pointers.

    In the physical implementation I cannot tell you the difference, but programatically; void mean no return value and null is no object assigned to the variable.

  • In-Place Element Structures, References and Pointers, Compiler Optimization, and General Stupidity

    [The title of this forum is "Labview Ideas". Although this is NOT a direct suggestion for a change or addition to Labview, it seems appropriate to me to post it in this forum.]
    In-Place Element Structures, References and Pointers, Compiler Optimization, and General Stupidity
    I'd like to see NI actually start a round-table discussion about VI references, Data Value references, local variables, compiler optimizations, etc. I'm a C programmer; I'm used to pointers. They are simple, functional, and well defined. If you know the data type of an object and have a pointer to it, you have the object. I am used to compilers that optimize without the user having to go to weird lengths to arrange it. 
    The 'reference' you get when you right click and "Create Reference" on a control or indicator seems to be merely a shorthand read/write version of the Value property that can't be wired into a flow-of-control (like the error wire) and so causes synchronization issues and race conditions. I try not to use local variables.
    I use references a lot like C pointers; I pass items to SubVIs using references. But the use of references (as compared to C pointers) is really limited, and the implementation is insconsistent, not factorial in capabilites, and buggy. For instance, why can you pass an array by reference and NOT be able to determine the size of the array EXCEPT by dereferencing it and using the "Size Array" VI? I can even get references for all array elements; but I don't know how many there are...! Since arrays are represented internally in Labview as handles, and consist of basically a C-style pointer to the data, and array sizing information, why is the array handle opaque? Why doesn't the reference include operators to look at the referenced handle without instantiating a copy of the array? Why isn't there a "Size Array From Reference" VI in the library that doesn't instantiate a copy of the array locally, but just looks at the array handle?
    Data Value references seem to have been invented solely for the "In-Place Element Structure". Having to write the code to obtain the Data Value Reference before using the In-Place Element Structure simply points out how different a Labview reference is from a C pointer. The Labview help page for Data Value References simply says "Creates a reference to data that you can use to transfer and access the data in a serialized way.".  I've had programmers ask me if this means that the data must be accessed sequentially (serially)...!!!  What exactly does that mean? For those of use who can read between the lines, it means that Labview obtains a semaphore protecting the data references so that only one thread can modify it at a time. Is that the only reason for Data Value References? To provide something that implements the semaphore???
    The In-Place Element Structure talks about minimizing copying of data and compiler optimization. Those kind of optimizations are built in to the compiler in virtually every other language... with no special 'construct' needing to be placed around the code to identify that it can be performed without a local copy. Are you telling me that the Labview compiler is so stupid that it can't identify certain code threads as needing to be single-threaded when optimizing? That the USER has to wrap the code in semaphores before the compiler can figure out it should optimize??? That the compiler cannot implement single threading of parts of the user's code to improve execution efficiency?
    Instead of depending on the user base to send in suggestions one-at-a-time it would be nice if NI would actually host discussions aimed at coming up with a coherent and comprehensive way to handle pointers/references/optimization etc. One of the reasons Labview is so scattered is because individual ideas are evaluated and included without any group discussion about the total environment. How about a MODERATED group, available by invitation only (based on NI interactions with users in person, via support, and on the web) to try and get discussions about Labview evolution going?
    Based solely on the number of Labview bugs I've encountered and reported, I'd guess this has never been done, with the user community, or within NI itself.....

    Here are some articles that can help provide some insights into LabVIEW programming and the LabVIEW compiler. They are both interesting and recommended reading for all intermediate-to-advanced LabVIEW programmers.
    NI LabVIEW Compiler: Under the Hood
    VI Memory Usage
    The second article is a little out-of-date, as it doesn't discuss some of the newer technologies available such as the In-Place Element Structure you were referring to. However, many of the general concepts still apply. Some general notes from your post:
    1. I think part of your confusion is that you are trying to use control references and local variables like you would use variables in a C program. This is not a good analogy. Control references are references to user interface controls, and should almost always be used to control the behavior and appearance of those controls, not to store or transmit data like a pointer. LabVIEW is a dataflow language. Data is intended to be stored or transmitted through wires in most cases, not in references. It is admittedly difficult to make this transition for some text-based programmers. Programming efficiently in LabVIEW sometimes requires a different mindset.
    2. The LabVIEW compiler, while by no means perfect, is a complicated, feature-rich set of machinery that includes a large and growing set of optimizations. Many of these are described in the first link I posted. This includes optimizations you'd find in many programming environments, such as dead code elimination, inlining, and constant folding. One optimization in particular is called inplaceness, which is where LabVIEW determines when buffers can be reused. Contrary to your statement, the In-Place Element Structure is not always required for this optimization to take place. There are many circumstances (dating back years before the IPE structure) where LabVIEW can determine inplaceness and reuse buffers. The IPE structure simply helps users enforce inplaceness in some situations where it's not clear enough on the diagram for the LabVIEW compiler to make that determination.
    The more you learn about programming in LabVIEW, the more you realize that inplaceness itself is the closest analogy to pointers in C, not control references or data references or other such things. Those features have their place, but core, fundamental LabVIEW programming does not require them.
    Jarrod S.
    National Instruments

  • How to Get RGB Values from a CMYK Color in the DOM (CS5)

    (CS5, Actionscript)
    Hi all,
    I have an InDesign document containing TextFrames whose border colors are specified as a CMYK array.
    I would like to be able to get its color specification as its closest RGB equivalent.
    Does the InDesign DOM contain a method for doing this for me automatically?  If not, what workarounds are there?
    TIA,
    mlavie

    Here's how to convert RGB to CMYK:
    function rgb2CMYK (r,g,b){
        var color = app.documents[0].colors.add({space:ColorSpace.RGB,colorValue:[r,g,b]});
        color.space = ColorSpace.CMYK;
        var retVal = color.colorValue;
        color.remove();
        return retVal;
    The same idea for the reverse.
    For info on converting to grayscale, check out this:
    http://in-tools.com/article/scripts-blog/convert-colors-to-grayscal-in-indesign/
    HTH,
    Harbs

  • I am trying to setup wireless using my old dome Airport ExtremeBase station. I had previously used it about 5 years ago when I had dial up but have now switche to DSL with Windstream. I can not get connecte as ABS keeps trying to dial up(the phone number)

    I am trying to setup wireless using my old dome Airport Extreme Base station. I had previously used it about 5 years ago when I had dial up but have now switched to DSL with Windstream. I can not get connected as the ABS keeps trying to dial up(the old phone number). When I tried to change my network settings an annoying popup window says "your network settings have been changed by another application'. I have no idea what the message is all about and when I close this window it immediately pops up again and prevents me -as far as I can tell -from changing my Airport settings?  I need advice on how to get this wireless setup done. Maybe a reset? or something else? I have the DSL phone line plugged into WIndsteam Seimens Speedstream 4200 modem and then the ethernet (yellow) wire from the WIndsteam Seimens Speedstream 4200 modem to the port on the dome that is a circle of dots.

    1)Can you explain how using the AEBS as a bridge will work with the Seimens Speedstream4200?
    As a bridge, the AEBS will basically become a wireless access point. This will allow the AEBS to provide a wireless network, but still allow the Speedstream to provide NAT & DHCP services for the wireless clients connected to the AEBS. If the AEBS was left as a router, you would have a double-NAT condition which isn't necessary bad in itself, but would create a second subnet. That would make it more difficult for clients connected to the AEBS to access clients connected to the Speedstream.
    2) Is there a link that will guide me through the steps to set the AEBS as a bridge?
    You can easily reconfigure the AEBS as a bridge using the AirPort Utility.
    ref: AirPort Utility > Select the AEBS > Manual Setup > Internet > Internet Connection > Connection Sharing = Off (Bridge Mode)
    3)Can I just connect the DSL phone line to the AEBS and eliminate the Speedstream4200?
    Unfortunately no. The AEBS does not have a built-in DSL modem. You will still need the Speedstream to provide this function.

  • I am trying to rebuild my iPhoto library and noticed my backup contains aliases (pointers?) and not the actual file. What's the best way to rebuild my library?

    I am trying to rebuild my iPhoto library and noticed my backup contains aliases (pointers?) and not the actual file. What's the best way to rebuild my library?
    Facts:
    In moving to a new iMac, I copied the iPhoto library to an external HDD assuming that I would point the new iMac to the backed up iPhoto Library
    All worked fine when I pointed the new library but noticed that some folders contained aliases and not the original file. So when I attempt to open that photo it can't find it because the alias is pointing to another drive.
    I do have all original photos from a couple of external HDDs. In the folders titled, "Originals" (from older versions of iPhoto) and "Masters" (from current iPhoto)
    I'm thinking I can create a new folder and drop the original files and make that my new iPhoto library. Is there a better way to rebuild my library? I do not want to create any future aliases.
    Thanks in advance for any help!

    do you have a strongly recommended default "managed" library (the iPhoto preference to "copy imported items to the iPhoto library is in its checked state) or a referenced library - you have unchecked that option?
    It sounds like you have a referenced library and are now experiancing one of the very siginificant drawbacks of a referenced library and one of the many reasons they are strongly not recommended
    Also note that iPhoto '11 may use alises in the originals folder as part of the upgrade
    It is important that we understand exactly what you have and what is not sorking - what error messages you are getting
    You must NEVER make any changes of any sort to the structure of content of the iPhoto library - there are no user servicable parts in it  --  and you can not rebuild yoru librtary - only iPhoto ir iPhoto Library Manager - http://www.fatcatsoftware.com/iplm/ -  can rebuild a library unless you are a SQL programmer and understand the structure that iPhoto uses
    LN

  • Oracle XML DOM parser - attribute values are not printing on the screen ??

    Hi Everyone,
    I am just trying to use oracle DOM parser to paerse one of my xml file, java file can be compiled and run agianst a xml file, But I cannot see any attribute values printing on the screen..
    Appreciate if anyone can help, where I have gone wrong please?
    Below is the java file:
    // menna puthe DOMSample eka - duwanawa 19/12/2005
    import java.io.*;
    import java.net.*;
    import org.w3c.dom.*;
    import org.w3c.dom.Node;
    import oracle.xml.parser.v2.*;
    public class DOMSample {  //public class eka ***
    static public void main(String[] argv){  // main method eka ###
    try {
    if (argv.length != 1){
    // Must pass in the name of the XML file...
    System.err.println("Usage: java DOMSample filename");
    System.exit(1);
    // Get an instance of the parser
    DOMParser parser = new DOMParser();
    // Generate a URL from the filename.
    URL url = createURL(argv[0]);
    // Set various parser options: validation on,
    // warnings shown, error stream set to stderr.
    parser.setErrorStream(System.err);
    parser.showWarnings(true);
    // Parse the document.
    parser.parse(url);
    // Obtain the document.
    Document doc = parser.getDocument();
    // Print document elements
    System.out.print("The elements are: ");
    printElements(doc);
    // Print document element attributes
    System.out.println("The attributes of each element are: ");
    printElementAttributes(doc);
    catch (Exception e){
    System.out.println(e.toString());
    } // main method eka ###
    static void printElements(Document doc) {
    NodeList nl = doc.getElementsByTagName("*");
    Node n;
    for (int i=0; i<nl.getLength(); i++){
    n = nl.item(i);
    System.out.print(n.getNodeName() + " ");
    System.out.println();
    static void printElementAttributes(Document doc){
    NodeList nl = doc.getElementsByTagName("*");
    Element e;
    Node n;
    NamedNodeMap nnm;
    String attrname;
    String attrval;
    int i, len;
    len = nl.getLength();
    for (int j=0; j < len; j++){
    e = (Element)nl.item(j);
    System.out.println(e.getTagName() + ":");
    nnm = e.getAttributes();
    if (nnm != null){
    for (i=0; i<nnm.getLength(); i++){
    n = nnm.item(i);
    attrname = n.getNodeName();
    attrval = n.getNodeValue();
    System.out.print(" " + attrname + " = " + attrval);
    System.out.println();
    static URL createURL(String filename) {  // podi 3 Start
    URL url = null;
    try {
    url = new URL(filename);
    } catch (MalformedURLException ex) { /// BBBBBB
    try {
    File f = new File(filename);
    url = f.toURL();
    } catch (MalformedURLException e) {
    System.out.println("Cannot create URL for: " + filename);
    System.exit(0);
    } // BBBBBB
    return url;
    } // podi 3 End
    } //public class eka ***
    // End of program
    output comes as below:
    Isbn:
    Title:
    Price:
    Author:
    Message was edited by:
    chandanal

    Hi Chandanal,
    I edited your code slightly and I was able to get the correct output.
    I changed the following line:
    for (int j=0; j >< len; j++)to:
    for (int j=0; j < len; j++)I have included the complete source below:
    // menna puthe DOMSample eka - duwanawa 19/12/2005
    import java.io.*;
    import java.net.*;
    import org.w3c.dom.*;
    import org.w3c.dom.Node;
    import oracle.xml.parser.v2.*;
    public class DOMSample {
        //public class eka ***
        public static void main(String[] argv) {
            // main method eka ###
            try {
                if (argv.length != 1) {
                    // Must pass in the name of the XML file...
                    System.err.println("Usage: java DOMSample filename");
                    System.exit(1);
                // Get an instance of the parser
                DOMParser parser = new DOMParser();
                // Generate a URL from the filename.
                URL url = createURL(argv[0]);
                // Set various parser options: validation on,
                // warnings shown, error stream set to stderr.
                parser.setErrorStream(System.err);
                parser.showWarnings(true);
                // Parse the document.
                parser.parse(url);
                // Obtain the document.
                Document doc = parser.getDocument();
                // Print document elements
                System.out.print("The elements are: ");
                printElements(doc);
                // Print document element attributes
                System.out.println("The attributes of each element are: ");
                printElementAttributes(doc);
            } catch (Exception e) {
                System.out.println(e.toString());
        // main method eka ###
        static void printElements(Document doc) {
            NodeList nl = doc.getElementsByTagName("*");
            Node n;
            for (int i = 0; i < nl.getLength(); i++) {
                n = nl.item(i);
                System.out.print(n.getNodeName() + " ");
            System.out.println();
        static void printElementAttributes(Document doc) {
            NodeList nl = doc.getElementsByTagName("*");
            Element e;
            Node n;
            NamedNodeMap nnm;
            String attrname;
            String attrval;
            int i, len;
            len = nl.getLength();
            for (int j = 0; j < len; j++) {
                e = (Element)nl.item(j);
                System.out.println(e.getTagName() + ":");
                nnm = e.getAttributes();
                if (nnm != null) {
                    for (i = 0; i < nnm.getLength(); i++) {
                        n = nnm.item(i);
                        attrname = n.getNodeName();
                        attrval = n.getNodeValue();
                        System.out.print(" " + attrname + " = " + attrval);
                System.out.println();
        static URL createURL(String filename) {
            // podi 3 Start
            URL url = null;
            try {
                url = new URL(filename);
            } catch (MalformedURLException ex) {
                /// BBBBBB
                try {
                    File f = new File(filename);
                    url = f.toURL();
                } catch (MalformedURLException e) {
                    System.out.println("Cannot create URL for: " + filename);
                    System.exit(0);
            // BBBBBB
            return url;
        // podi 3 End
    } //public class eka ***-Blaise

Maybe you are looking for