You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xmlbeans.apache.org by "Auber Lin (JIRA)" <xm...@xml.apache.org> on 2006/11/10 09:28:39 UTC
[jira] Created: (XMLBEANS-296) Xml comments are ignored by XmlBeans
Xml comments are ignored by XmlBeans
------------------------------------
Key: XMLBEANS-296
URL: http://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.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: dev-help@xmlbeans.apache.org
[jira] Commented: (XMLBEANS-296) Xml comments are ignored by
XmlBeans
Posted by "Jacob Danner (JIRA)" <xm...@xml.apache.org>.
[ http://issues.apache.org/jira/browse/XMLBEANS-296?page=comments#action_12451986 ]
Jacob Danner commented on XMLBEANS-296:
---------------------------------------
I've seen this to via something like:
String fooXml = "<root><!-- comment --><baz>a</baz></root>";
XmlObject xObj = XmlObject.Factory.parse(fooXml);
System.out.println(xObj.xmlText());
will display:
<root><baz>a</baz></root>
It looks like this 'feature' has been around since v1
> Xml comments are ignored by XmlBeans
> ------------------------------------
>
> Key: XMLBEANS-296
> URL: http://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.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: dev-help@xmlbeans.apache.org
RE: [jira] Updated: (XMLBEANS-296) Xml comments are ignored by XmlBeans
Posted by "Webber, David (NIH/OD) [C]" <we...@od.nih.gov>.
Just FYI - this is why the W3C introduced the annotation element and
approach with XSD.
DW
-----Original Message-----
From: Cezar Andrei (JIRA) [mailto:xmlbeans-dev@xml.apache.org]
Sent: Wednesday, November 22, 2006 11:18 AM
To: xmlbeans-dev@xml.apache.org
Subject: [jira] Updated: (XMLBEANS-296) Xml comments are ignored by
XmlBeans
[ http://issues.apache.org/jira/browse/XMLBEANS-296?page=all ]
Cezar Andrei updated XMLBEANS-296:
----------------------------------
Comments are not associated with any sibling elements, so removing any
of the sibling elements will no remove the comment.
You need to explicitly delete the comment. The comments will only get
deleted if their parent element is deleted.
> Xml comments are ignored by XmlBeans
> ------------------------------------
>
> Key: XMLBEANS-296
> URL: http://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.
-
If you think it was sent incorrectly contact one of the administrators:
http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: dev-help@xmlbeans.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: dev-help@xmlbeans.apache.org
[jira] Updated: (XMLBEANS-296) Xml comments are ignored by XmlBeans
Posted by "Cezar Andrei (JIRA)" <xm...@xml.apache.org>.
[ http://issues.apache.org/jira/browse/XMLBEANS-296?page=all ]
Cezar Andrei updated XMLBEANS-296:
----------------------------------
Comments are not associated with any sibling elements, so removing any of the sibling elements will no remove the comment.
You need to explicitly delete the comment. The comments will only get deleted if their parent element is deleted.
> Xml comments are ignored by XmlBeans
> ------------------------------------
>
> Key: XMLBEANS-296
> URL: http://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.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: dev-help@xmlbeans.apache.org
[jira] Commented: (XMLBEANS-296) Xml comments are ignored by
XmlBeans
Posted by "Auber Lin (JIRA)" <xm...@xml.apache.org>.
[ http://issues.apache.org/jira/browse/XMLBEANS-296?page=comments#action_12449251 ]
Auber Lin commented on XMLBEANS-296:
------------------------------------
Here i posted a part of my code to remove the ith library instance element from ModuleSA element with key. As the library instances were added with comments (i use insertComment() from XmlCursor), deleting these library instances should also delete those comments added.
But the result is that comments are left untouched and library instances are removed.
public void removeLibraryInstance(String key, int i) {
ModuleSADocument.ModuleSA msa = getModuleSA(key);
if (msa == null || msa.getLibraries() == null){
return ;
}
XmlCursor cursor = msa.getLibraries().newCursor();
if (cursor.toFirstChild()) {
for (int j = 0; j < i; ++j) {
cursor.toNextSibling();
}
cursor.push();
// Try to get the comment part by moving cursor
while (cursor.hasPrevToken()) {
cursor.toPrevToken();
if (!cursor.isText()) {
break;
}
String s = cursor.getTextValue();
if (s.matches(regExpNewLineAndSpaces)) {
continue;
}
}
if (cursor.isComment()) {
cursor.removeXml();
}
cursor.pop();
cursor.removeXml();
if (getLibraryInstancesCount(key) == 0) {
cursor.toParent();
cursor.removeXml();
}
}
cursor.dispose();
}
> Xml comments are ignored by XmlBeans
> ------------------------------------
>
> Key: XMLBEANS-296
> URL: http://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.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: dev-help@xmlbeans.apache.org
[jira] Commented: (XMLBEANS-296) Xml comments are ignored by
XmlBeans
Posted by "Cezar Andrei (JIRA)" <xm...@xml.apache.org>.
[ http://issues.apache.org/jira/browse/XMLBEANS-296?page=comments#action_12448750 ]
Cezar Andrei commented on XMLBEANS-296:
---------------------------------------
Did you try using the XmlCursor's insertComment(), get/set TextValue() on the comment event and removeXml()?
To get an XmlCursor from an XmlObject use:
XmlCursor xc = xmlObject.newCursor();
xc. .... // do stuff with cursor
xc.dispose();
Please let us know if those methods worked for you.
> Xml comments are ignored by XmlBeans
> ------------------------------------
>
> Key: XMLBEANS-296
> URL: http://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.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: dev-help@xmlbeans.apache.org
RE: [jira] Commented: (XMLBEANS-296) Xml comments are ignored by XmlBeans
Posted by "Webber, David (NIH/OD) [C]" <we...@od.nih.gov>.
The official approach from W3C is to use annotation elements.
See W3C documentation on XSD and annotation.
DW
-----Original Message-----
From: Auber Lin (JIRA) [mailto:xmlbeans-dev@xml.apache.org]
Sent: Thursday, November 23, 2006 9:13 AM
To: xmlbeans-dev@xml.apache.org
Subject: [jira] Commented: (XMLBEANS-296) Xml comments are ignored by
XmlBeans
[
http://issues.apache.org/jira/browse/XMLBEANS-296?page=comments#action_1
2452250 ]
Auber Lin commented on XMLBEANS-296:
------------------------------------
Then i feel it not reasonable for detaching comments from XML body, how
can we embody those comments when creating an XmlBeans document object?
> Xml comments are ignored by XmlBeans
> ------------------------------------
>
> Key: XMLBEANS-296
> URL: http://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.
-
If you think it was sent incorrectly contact one of the administrators:
http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: dev-help@xmlbeans.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: dev-help@xmlbeans.apache.org
[jira] Commented: (XMLBEANS-296) Xml comments are ignored by
XmlBeans
Posted by "Auber Lin (JIRA)" <xm...@xml.apache.org>.
[ http://issues.apache.org/jira/browse/XMLBEANS-296?page=comments#action_12452250 ]
Auber Lin commented on XMLBEANS-296:
------------------------------------
Then i feel it not reasonable for detaching comments from XML body, how can we embody those comments when creating an XmlBeans document object?
> Xml comments are ignored by XmlBeans
> ------------------------------------
>
> Key: XMLBEANS-296
> URL: http://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.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: dev-help@xmlbeans.apache.org
[jira] Resolved: (XMLBEANS-296) Xml comments are ignored by
XmlBeans
Posted by "Cezar Andrei (JIRA)" <xm...@xml.apache.org>.
[ 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: dev-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: dev-help@xmlbeans.apache.org
[jira] Commented: (XMLBEANS-296) Xml comments are ignored by
XmlBeans
Posted by "Auber Lin (JIRA)" <xm...@xml.apache.org>.
[ http://issues.apache.org/jira/browse/XMLBEANS-296?page=comments#action_12449248 ]
Auber Lin commented on XMLBEANS-296:
------------------------------------
Andrei, i did use XmlCursor.insertComment() to add comments to an xml file, this works fine. But the problem is that when i open that xml file next time, those comments added before are not brought in by the xml document object that xmlBeans create. so when i operate the cursor, i can not find the comment tags and no way to edit them.
> Xml comments are ignored by XmlBeans
> ------------------------------------
>
> Key: XMLBEANS-296
> URL: http://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.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: dev-help@xmlbeans.apache.org