Removing ignorable whitespace from DOM document

Dear all,
I am trying to read in an XML document that contains a lot of ignorable whitespace between elements. I am using the DOM model to parse and read in the file. Is there an easy way to tell the parser to ignore all ignorable whitespace characters in text nodes? Or do I have to write a routine to pre-process the DOM document?
(xml:space="default" is set in the root element)
Thanks a lot in advance!
Netwundi

I agree DrClap with your assertion. However, having read normalize(), it does seem quirky. According to the Javadocs for Node:
public void normalize()
Puts all Text nodes in the full depth of the sub-tree underneath this Node, including attribute nodes, into a "normal" form where only structure (e.g., elements, comments, processing instructions, CDATA sections, and entity references) separates Text nodes, i.e., there are neither adjacent Text nodes nor empty Text nodes. This can be used to ensure that the DOM view of a document is the same as if it were saved and re-loaded, and is useful when operations (such as XPointer lookups) that depend on a particular document tree structure are to be used.In cases where the document contains CDATASections, the normalize operation alone may not be sufficient, since XPointers do not differentiate between Text nodes and CDATASection nodes.- Saish

Similar Messages

  • How to remove a page from Pages document

    I have created a document in pages, and it is 12 pages. This is the complete document, originally created to export as a PDF.
    I want to create a smaller version of the document, removing certain pages that some people do not need.
    Unfortunately, I created the document as I went, and did not use sections of blank pages each time I started a new one. Is there any way I can remove a page from the document? Every time I try and go to thumbnail view and delete a page, it deletes all 12 pages. Thank you for any help you can give.

    When you click on the thumbnails it selects entire sections.
    To isolate a page/s, insert section breaks at the foot of the pages before and at the bottom of the one you want to select. Then click on that page/s in the thumbnail and hit delete.
    More sensibly you should delete the content in the document rather than thumbnail pages.
    If the pages you wiish to omit are at the beginning or end of the document, you can nominate the page numbers you wish to output in the Print dialog when printing to pdf.
    Peter

  • [svn:fx-trunk] 13358: Manually removing extraneous whitespace from the start of the en_US playerglobal rb DITA XML files to unblock the build .

    Revision: 13358
    Revision: 13358
    Author:   [email protected]
    Date:     2010-01-07 17:10:34 -0800 (Thu, 07 Jan 2010)
    Log Message:
    Manually removing extraneous whitespace from the start of the en_US playerglobal rb DITA XML files to unblock the build. We need to work with the doc team to make sure future drops do not contain this whitespace.
    QE notes: N/A
    Doc notes: N/A
    Bugs:
    SDK-24896 - playerglobal_rb.swc has dita content that is not encoded correctly
    Reviewer: For Jim, Jeff
    Tests run: ant other.locales
    Is noteworthy for integration: Yes
    Ticket Links:
        http://bugs.adobe.com/jira/browse/SDK-24896
    Modified Paths:
        flex/sdk/trunk/frameworks/projects/playerglobal/bundles/en_US/docs/__Global__.xml
        flex/sdk/trunk/frameworks/projects/playerglobal/bundles/en_US/docs/air.net.xml
        flex/sdk/trunk/frameworks/projects/playerglobal/bundles/en_US/docs/air.update.events.xml
        flex/sdk/trunk/frameworks/projects/playerglobal/bundles/en_US/docs/air.update.xml
        flex/sdk/trunk/frameworks/projects/playerglobal/bundles/en_US/docs/authoring.xml
        flex/sdk/trunk/frameworks/projects/playerglobal/bundles/en_US/docs/flash.accessibility.xm l
        flex/sdk/trunk/frameworks/projects/playerglobal/bundles/en_US/docs/flash.data.xml
        flex/sdk/trunk/frameworks/projects/playerglobal/bundles/en_US/docs/flash.desktop.xml
        flex/sdk/trunk/frameworks/projects/playerglobal/bundles/en_US/docs/flash.display.xml
        flex/sdk/trunk/frameworks/projects/playerglobal/bundles/en_US/docs/flash.errors.xml
        flex/sdk/trunk/frameworks/projects/playerglobal/bundles/en_US/docs/flash.events.xml
        flex/sdk/trunk/frameworks/projects/playerglobal/bundles/en_US/docs/flash.external.xml
        flex/sdk/trunk/frameworks/projects/playerglobal/bundles/en_US/docs/flash.filesystem.xml
        flex/sdk/trunk/frameworks/projects/playerglobal/bundles/en_US/docs/flash.filters.xml
        flex/sdk/trunk/frameworks/projects/playerglobal/bundles/en_US/docs/flash.geom.xml
        flex/sdk/trunk/frameworks/projects/playerglobal/bundles/en_US/docs/flash.html.xml
        flex/sdk/trunk/frameworks/projects/playerglobal/bundles/en_US/docs/flash.media.xml
        flex/sdk/trunk/frameworks/projects/playerglobal/bundles/en_US/docs/flash.net.drm.xml
        flex/sdk/trunk/frameworks/projects/playerglobal/bundles/en_US/docs/flash.net.xml
        flex/sdk/trunk/frameworks/projects/playerglobal/bundles/en_US/docs/flash.printing.xml
        flex/sdk/trunk/frameworks/projects/playerglobal/bundles/en_US/docs/flash.profiler.xml
        flex/sdk/trunk/frameworks/projects/playerglobal/bundles/en_US/docs/flash.sampler.xml
        flex/sdk/trunk/frameworks/projects/playerglobal/bundles/en_US/docs/flash.security.xml
        flex/sdk/trunk/frameworks/projects/playerglobal/bundles/en_US/docs/flash.system.xml
        flex/sdk/trunk/frameworks/projects/playerglobal/bundles/en_US/docs/flash.text.engine.xml
        flex/sdk/trunk/frameworks/projects/playerglobal/bundles/en_US/docs/flash.text.xml
        flex/sdk/trunk/frameworks/projects/playerglobal/bundles/en_US/docs/flash.ui.xml
        flex/sdk/trunk/frameworks/projects/playerglobal/bundles/en_US/docs/flash.utils.xml
        flex/sdk/trunk/frameworks/projects/playerglobal/bundles/en_US/docs/flash.xml.xml

    Thats good news.

  • How do I remove edit markings from final document

    How do I remove edit markings from final document? There are slash marks at the beginning of each row of typing and little arrowheads where I made changes to typing.

    What program did you use to edit the document? If you used Word for Mac then you might want to ask your question in the Office for Mac foums http://answers.microsoft.com/en-us/mac?auth=1.
    If you used some other program, you will need to tell us which one.

  • Removing pw-protection from multiple documents using v. 11.0.4

    I'm hoping someone can help me out here. I'm at my wit's end after wasting an hour and a half with an Adobe chat person who couldn't figure this out.
    In previous versions of Acrobat, one was able to add pw-protection to multiple documents at once using the batch process, and conversely, one was able to REMOVE that pw-protection using a similar batch process. I now have about 150 documents that all have the same password, which I must remove because of the need for edits. In v. 11.0.4, however, this capability seems to have disappeared. The chat support person said the only way to do it was to create an Action, but then be willing to re-enter the pw for each and every file! 150 times! Surely we haven't gone backwards in this version?! Say it ain't so!
    If anyone knows how to do this, I would be very grateful. It seems a shame that I would have to revert to an older version to get this job done (with the hassle of uninstalling/installing to boot).
    Thanks,
    Gail

    Hi Dave,
    OK I’ve downloaded your  file and installed. The option Remove Security appears under the Encrypt action only if I have a file open and it will indeed remove the pw from that file and allow me to save back to the same file name. However I don’t see an option to add multiple files to the action, and if no file is open, the action is dimmed out. This is my last hurdle to getting this job done; can you point me in the right direction?
    Gail

  • How do I remove trailing whitespace from code.

    Dreamweaver likes to put a lot of tabs and spaces in the code I write.   Is there a way to strip all these whitespace characters when I save the file?   I've seen some statistics saying that removing the whitespace generated by Dreamweaver can reduce file sizes by up to 5%.   Thanks in advance for the tips.

    Murray, here's proof that this is the case.  Sorry for the resolution, but you can see what I mean.
    http://www.youtube.com/watch?v=C2EO_ZVnGWc
    Oh, and evidently adobe's forums are broken... there is an option to insert youtube but it doesn't work.  Tried twice now. Lovely.

  • HELP!? Remove 1 page from long document and shift all the rest pages

    Hello,
    I am facing to following problem:
    I have a long document with facing pages. Now I need to remove one left page in the middle of the document and shift all the rest pages one step forward. It means from all right pages do a left and vice versa (started from the page that was removed). There is a continous text int the whole document and left/right strip made from different photos.
    To clarify the situation I am attaching the preview. I have deleted page no.12 and I need to shift page 13 to left, 14 to right after 13, 15 to left, 16 to right after 15 and so on....
    Is there any simple way how to do it?
    Thank you very much for any tips.

    It looks to me as if you may something else going on here. Are you using right-to-left text here so the document binding would be onthe right when the book is closed? If not, your problem is not with page 13 so much as it is with the earlier pages.
    Unless you force it to do otherwise by disabling page shuffling someplace, in left-to-right documents using facing pages ID will always put odd numbered pages to the right of the spine and even to the left, the opposite for right-to-left documents. In either case, it seems like you have page shuffling disabled either for the whole file or for a selected spread. You can re-enable it from the menu in the Pages panel. When ID asks if you want to maintain the current number of pages on a spread you should probably say no. Either pages 1-12 will swtch sides, or 13 and following will, and your spreads will rearrange to put two pages together as they should be.
    If you  have overridden master page objects, a side effect of switching sides on the spread will be that the overridden objects will remain and the new master objects from the other side of the spread will appear behind them.

  • How can I remove section dividers from Pages document?

    I would like to remove the section dividers in a Pages document so that all pages are a part of one section, not several. I would like to be able to number the pages consecutively from beginning to end of the document.
    Thank you.

    Section Breaks are characters, so you can just forward or backward delete them.
    You can also set the document to continue numbering from the previous section.
    Peter

  • Is there a way to remove a password from a Document?  We have a form that an ex employee created and didn't reveal the password to anyone before he left

    We have a document that a former employee created and password protected.  He left without revealing the password to anyone and now we need to make changes to the form.  Is there a way to remove the security?

    Hello Kelly,
    if you can't negotiate a private agreement, there is no possibility to recover this document. Then the only way is, that you copy the contents or create a new one according to your wishes.
    Hans-Günter

  • How do i remove a password from a document to make it readable

    I have attached a password to a document and want to remove it now how do i do this

    Hi kmack2010 ,
    Thank you for posting on the Adobe forums, firstly you need to have the Password in order to remove it. Secondly it cannot be done using adobe Reader, you need acrobat to achieve this.
    Thanks,
    Vikrantt Singh

  • Remove default classification from SAP documents (CL24N / CV02N)

    Hi gurus,
    I've this scenario I need to solve.
    Via Customizing, I've linked a class document with a Class. (Transaction DC10).
    After that, when I create a document, a class is assigned by default, according with this previous customizing.
    However, we've noticed that we need to remove this default classification in some documents, but just in some of them.
    It is possible to delete this assignation? I've tested with CL24, CV02N, and the result is not good at all.
    How can I delete his relation between classes and documents definitely??
    A lot of thanks!!!

    Hi
    Do not assign Default Class in dc10. Make the indicator Classifcation optional entry in field selection and in cv01n / cv02n use classifcaion tab , find the class and add to the dir wher ever needed.
    Regards
    Aby

  • HT3384 how to remove (delete) shapes from pages document or move them once they are in place

    How can I delete or move a shape once I put it in a document?

    If you are having trouble selecting the shape, try holding down the command key and clicking on its edge so you see the corner selection boxes, then hit the Delete key.
    Peter

  • How do I remove password protection from a document so I can upload it to a secure site that does not accept protected documents due to their firewall?

    Please help with the questions above.

    If a website doesn't offer to store the password then chances are that it doesn't fill that password either if you use the "Saved Passwords Editor" extension. You can only use that extension in such a case as a reminder in case you forget the password.
    See also http://kb.mozillazine.org/User_name_and_password_not_remembered

  • How to remove empty lines from xml files after removing nodes from document

    <pre>
    Hi
    <b>i have xml document, which is shown below
    after removing some nodes from the document ,i am getting empty lines in place of removed nodes,how to resolve this and get the proper xml document without any errors</b>
    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <!DOCTYPE Message SYSTEM "TRD01.dtd">
    <Message>
    <Header>
    <CounterPartyType>CLIENT</CounterPartyType>
    <CreationTime>20134455</CreationTime>
    <ErrorCode>363 </ErrorCode>
    <ErrorEnterPriseId>N</ErrorEnterPriseId>
    <ErrorStatus>1</ErrorStatus>
    <ErrorSystemId>STL</ErrorSystemId>
    <ErrorTimes>31</ErrorTimes>
    <MessageType>T</MessageType>
    <RecipientEnterpriseId>N</RecipientEnterpriseId>
    <RecipentSystemId>EXM</RecipentSystemId>
    <Remarks>REMARSK</Remarks>
    <SenderEnterpriseId>N</SenderEnterpriseId>
    <SenderSystemId>TR</SenderSystemId>
    </Header>
    </Message>
    <ErrorCode>363 </ErrorCode>
    <ErrorEnterPriseId>NIHK</ErrorEnterPriseId>
    <ErrorStatus>1</ErrorStatus>
    <ErrorSystemId>STL</ErrorSystemId>
    <ErrorTimes>31</ErrorTimes>
    XPathExpression expression5 = xpath.compile(xmlpath5);
    Object result5 = expression5.evaluate(doc, XPathConstants.NODE);
    Node node5 = (Node) result5;
    node5.getParentNode().removeChild(node5);
    XPathExpression expression6 = xpath.compile(xmlpath6);
    Object result6 = expression6.evaluate(doc, XPathConstants.NODE);
    Node node6=(Node) result6;
    node6.getParentNode().removeChild(node6);
    XPathExpression expression7 = xpath.compile(xmlpath7);
    Object result7 = expression7.evaluate(doc, XPathConstants.NODE);
    Node node7=(Node) result7;
    node7.getParentNode().removeChild(node7);
    doc.normalize();
    doc.normalizeDocument();
    TransformerFactory tf = TransformerFactory.newInstance();
    Transformer t = tf.newTransformer();
    t.setOutputProperty(OutputKeys.INDENT, "yes");
    t.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4");
    t.setOutputProperty(OutputKeys.METHOD,"xml");
    t.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
    the xml output i am getting is
    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <Message>
    <Header>
    <CounterPartyType>CLIENT</CounterPartyType>
    <CreationTime>20134455</CreationTime>
    <MessageType>TRD01</MessageType>
    <RecipientEnterpriseId>N</RecipientEnterpriseId>
    <RecipentSystemId>STL</RecipentSystemId>
    <Remarks>REMARSK</Remarks>
    <SenderEnterpriseId>N</SenderEnterpriseId>
    <SenderSystemId>T</SenderSystemId>
    </Header>
    </Message>
    <b>could you please let me know how to avoid empty lines in the xml doucment output</b>
    this is the method i am using to get the result
    public void ValidateRecord(String xml){
    try{
    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    DocumentBuilder db = factory.newDocumentBuilder();
    //parse file into DOM
    /*DOMParser parser = new DOMParser();
    parser.setErrorStream(System.err);
    parser.setValidationMode(DTD_validation);
    parser.showWarnings(true);*/
    System.out.println ("HI THIS xml is validation "+xml);
    Resolver res = new Resolver();
    db.setEntityResolver(res);
    Document doc = db.parse(new InputSource(new StringReader(xml)));
    XPathFactory xpf = XPathFactory.newInstance();
    XPath xpath = xpf.newXPath();
    // XPathExpression expression = xpath.compile("//A/B[C/E/text()=13]");
    String xmlpath="/Message/Header/CounterPartyType/text()";
    String xmlpath1="/Message/Header/RecipentSystemId/text()";
    String xmlpath2="/Message/Header/ErrorSystemId/text()";
    XPathExpression expression = xpath.compile(xmlpath);
    XPathExpression expression1 = xpath.compile(xmlpath2);
    Object result = expression.evaluate(doc, XPathConstants.NODE);
    Object result1 = expression1.evaluate(doc, XPathConstants.NODE);
    Node node = (Node) result;
    Node node1 = (Node) result1;
    System.out.println("the values of the string is " +node.getNodeValue());
    System.out.println("the values of the string is " +node1.getNodeValue());
    // for (int i = 0; i < nodes.getLength(); i++) {
    //System.out.println(nodes.item(i).getNodeValue());
    // CAHNGING THE RECEIPENT NODE
    XPathExpression expression2 = xpath.compile(xmlpath1);
    Object result2 = expression2.evaluate(doc, XPathConstants.NODE);
    Node node2 = (Node) result2;
    System.out.println(node2);
    node2.setNodeValue(node1.getNodeValue());
    System.out.println(node2);
    //removing the nodes from document
    String xmlpath3="/Message/Header/ErrorCode";
    String xmlpath4="/Message/Header/ErrorEnterPriseId";
    String xmlpath5="/Message/Header/ErrorStatus";
    String xmlpath6="/Message/Header/ErrorSystemId";
    String xmlpath7="/Message/Header/ErrorTimes";
    XPathExpression expression3 = xpath.compile(xmlpath3);
    Object result3 = expression3.evaluate(doc, XPathConstants.NODE);
    Node node3 = (Node) result3;
    node3.getParentNode().removeChild(node3);
    XPathExpression expression4 = xpath.compile(xmlpath4);
    Object result4 = expression4.evaluate(doc, XPathConstants.NODE);
    Node node4 = (Node) result4;
    System.out.println("node value");
    System.out.println(node4.getParentNode().getNodeName());
    node4.getParentNode().removeChild(node4);
    XPathExpression expression5 = xpath.compile(xmlpath5);
    Object result5 = expression5.evaluate(doc, XPathConstants.NODE);
    Node node5 = (Node) result5;
    node5.getParentNode().removeChild(node5);
    XPathExpression expression6 = xpath.compile(xmlpath6);
    Object result6 = expression6.evaluate(doc, XPathConstants.NODE);
    Node node6=(Node) result6;
    node6.getParentNode().removeChild(node6);
    XPathExpression expression7 = xpath.compile(xmlpath7);
    Object result7 = expression7.evaluate(doc, XPathConstants.NODE);
    Node node7=(Node) result7;
    node7.getParentNode().removeChild(node7);
    // Node b13Node = (Node) expression.evaluate(doc, XPathConstants.NODE);
    //b13Node.getParentNode().removeChild(b13Node);
    doc.normalize();
    doc.normalizeDocument();
    TransformerFactory tf = TransformerFactory.newInstance();
    Transformer t = tf.newTransformer();
    t.setOutputProperty(OutputKeys.INDENT, "yes");
    t.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4");
    t.setOutputProperty(OutputKeys.METHOD,"xml");
    t.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
    t.transform(new DOMSource(doc), new StreamResult(System.out));
    catch (Exception e) {
         e.printStackTrace();
    System.out.println(e.getMessage());
    </pre>
    Edited by: user12185243 on Apr 6, 2013 6:38 AM
    Edited by: user12185243 on Apr 6, 2013 6:41 AM
    Edited by: user12185243 on Apr 6, 2013 6:43 AM
    Edited by: user12185243 on Apr 6, 2013 6:45 AM
    Edited by: user12185243 on Apr 6, 2013 9:00 AM

    either this way we can do this
    1)
    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    <b> factory.setIgnoringElementContentWhitespace(true); </b>
    DocumentBuilder db = factory.newDocumentBuilder();
    or
    2)
    java.io.StringWriter sw = new java.io.StringWriter();
    StreamResult sr = new StreamResult(sw);
    t.transform(new DOMSource(doc), sr);
    String xml1 = sw.toString().trim();
    <b> xml1=xml1.replaceAll("\\s",""); </b>
    System.out.println(xml1.trim());

  • Removing Serial Number from Delivery

    Hi Folks,
      I have a requirement of Removing Serial Number from Delivery Document. Is there is some BAPI or FM available for this?
      Thanks in Advance,
      Punit

    Hi Anirban,
      I tried the FM. By Using the FM status of Serial Number 'Assigned to Delivery' is removed.
      But I could still see the Serial Number attached to Line Item in tran VL02N.
      Following is the code I have written.
    MOVE: '0085003031'     TO DA_SERXX-LIEF_NR,
            '000030'         TO DA_SERXX-POSNR,
            '0000034226'     to DA_SERXX-OBKNR,
            'M047SBX050034'  TO SERNO-SERNR.
            APPEND serno.
    CALL FUNCTION 'SERNR_DEL_FROM_DOCUMENT'
      EXPORTING
        objkopf                    = 'SER01'
        serxx                      = DA_SERXX
        operation                  = 'SDD1'
        MATERIAL                   = 'BM20847'
        j_vorgang                  = 'PMSA'
      BSTCH                      =
      BSTUP                      =
      DEL_COMPLETE               = ' '
      PROFILE                    =
      BUDAT                      =
    IMPORTING
      ANZSN                      =
      SERIAL_COMMIT              =
      STATUS_NOT_ALLOWED         =
    TABLES
       SERNR                      = serno
       R_SERNR                    = e_serno
    CHANGING
       T_SMESG                    =  t_msg
    EXCEPTIONS
       OBJECTLIST_NOT_FOUND       = 1
       PARAMETER_ERROR            = 2
       OTHERS                     = 3
    Please Let me know if I am worng someware.
    Thanks a lot,
    Punit

Maybe you are looking for