[ 
https://issues.apache.org/jira/browse/XMLBEANS-296?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Cezar Andrei resolved XMLBEANS-296.
-----------------------------------

    Resolution: Cannot Reproduce

It seems that comments and cursors work fine with the latest sources from SVN.
The following code has the expected result. Please reopen and attach a repro if 
you find a case that's not working.

        String fooXml = "<root><!-- comment --><baz>a</baz></root>";

        XmlObject xObj = XmlObject.Factory.parse(fooXml);
        System.out.println("1 with comment:\n" + xObj.xmlText());

        XmlOptions xo1 = new XmlOptions();
        xo1.setLoadStripComments();
        xObj = XmlObject.Factory.parse(fooXml, xo1);
        System.out.println("2 without comment:\n" + xObj.xmlText());

        XmlCursor xc = xObj.newCursor();
        xc.toFirstChild();
        xc.toNextToken();
        xc.insertComment("this is a newly inserted comment using XMLCursor");
        System.out.println("3 with comment:\n" + xObj.xmlText());

        xc.insertComment("another comment inserted with an XMLCursor");
        System.out.println("4 with two comments:\n" + xObj.xmlText());

        xc.toPrevToken();
        xc.toPrevToken();
        xc.removeXml();
        System.out.println("5 with one comment:\n" + xObj.xmlText());

Output:
1 with comment:
<root><!-- comment --><baz>a</baz></root>
2 without comment:
<root><baz>a</baz></root>
3 with comment:
<root><!--this is a newly inserted comment using XMLCursor--><baz>a</baz></root>
4 with two comments:
<root><!--this is a newly inserted comment using XMLCursor--><!--another 
comment inserted with an XMLCursor--><baz>a</baz></root>
5 with one comment:
<root><!--another comment inserted with an XMLCursor--><baz>a</baz></root>


> Xml comments are ignored by XmlBeans
> ------------------------------------
>
>                 Key: XMLBEANS-296
>                 URL: https://issues.apache.org/jira/browse/XMLBEANS-296
>             Project: XMLBeans
>          Issue Type: Bug
>    Affects Versions: Version 2.1
>         Environment: WindowsXp + JDK1.5.0-6
>            Reporter: Auber Lin
>            Priority: Blocker
>
> When a xml file contains some comments like <!--comment statements-->, these 
> comments are not included into the document object created by xmlbeans. so if 
> an application accessing xml file using xmlbeans, there is no way for it to 
> modify or delete these already-existed comments.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to