|
Thanks Cezar - while you're in there, I might add another comment. I was after a method to extract the attributes from a cursor and have this:
private static Map extractAttributes(XmlCursor cursor) { Bookmark bookmark = new Bookmark(); cursor.setBookmark(bookmark); if (cursor.isStartdoc()) cursor.toNextToken(); Map attributes = new HashMap(); if (cursor.toFirstAttribute()) { do attributes.put(cursor.getName(), cursor.getTextValue()); while (cursor.toNextAttribute()); } cursor.toBookmark(bookmark); return attributes; } The part I found curious was that I had to call toFirstAttribute before calling toNextAttribute, which I can understand, but it doesn't really provide for what I would imagine would be the typical usage pattern. It might be worth adding a comment on this in the javadoc as well. |
||||||||||||||||||||||||||||||||||||||||||||||||||
1. on START - goes to the first attribute of that element if one exists
2. on STARTDOC - goes to the first top level attribute of a document fragment - if STARTDOC is a docfrag and a top level attribute exists.
I'll add this comment to the java doc.