List Info

Thread: Created: (XMLBEANS-267) toFirstAttribute/toNextAttribute doesn't work




Created: (XMLBEANS-267) toFirstAttribute/toNextAttribute doesn't work
user name
2006-04-18 06:08:19
toFirstAttribute/toNextAttribute doesn't work
---------------------------------------------

         Key: XMLBEANS-267
         URL: htt
p://issues.apache.org/jira/browse/XMLBEANS-267
     Project: XMLBeans
        Type: Bug

  Components: XmlObject  
    Versions: Version 2.1    
 Environment: Windows XP, Intel, Sun JRE 1.5.0_04
    Reporter: Dmitri Colebatch


Either I'm misinterpreting the expected usage of
toNextAttribute, or it simply doesn't work.  Here's my
test code:

	public static void main(String[] args) throws Exception
	{
		XmlObject xml = XmlObject.Factory.parse(new
StringReader("<foo
a=\"x\"><bar>test</bar></foo
>"));
		XmlCursor cursor = xml.newCursor();
		boolean found = cursor.toFirstAttribute();
		System.out.println("found attribute: " +
found);
	}

And it outputs:

	found attribute: false

I'm assuming this is a bug as the javadoc implies this
should work.


-- 
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.atl
assian.com/software/jira


------------------------------------------------------------
---------
To unsubscribe, e-mail: dev-unsubscribexmlbeans.apache.org
For additional commands, e-mail: dev-helpxmlbeans.apache.org

Closed: (XMLBEANS-267) toFirstAttribute/toNextAttribute doesn't work
user name
2006-04-18 17:33:24
     [ http://issues.apache.org/jira/browse/XMLBEANS-267?page
=all ]
     
Cezar Andrei closed XMLBEANS-267:
---------------------------------

    Resolution: Fixed

The method XmlCuresor.toFirstAttribute() works from two
states:
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.

> toFirstAttribute/toNextAttribute doesn't work
> ---------------------------------------------
>
>          Key: XMLBEANS-267
>          URL: htt
p://issues.apache.org/jira/browse/XMLBEANS-267
>      Project: XMLBeans
>         Type: Bug

>   Components: XmlObject
>     Versions: Version 2.1
>  Environment: Windows XP, Intel, Sun JRE 1.5.0_04
>     Reporter: Dmitri Colebatch

>
> Either I'm misinterpreting the expected usage of
toNextAttribute, or it simply doesn't work.  Here's my
test code:
> 	public static void main(String[] args) throws
Exception
> 	{
> 		XmlObject xml = XmlObject.Factory.parse(new
StringReader("<foo
a=\"x\"><bar>test</bar></foo
>"));
> 		XmlCursor cursor = xml.newCursor();
> 		boolean found = cursor.toFirstAttribute();
> 		System.out.println("found attribute: " +
found);
> 	}
> And it outputs:
> 	found attribute: false
> I'm assuming this is a bug as the javadoc implies this
should work.

-- 
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.atl
assian.com/software/jira


------------------------------------------------------------
---------
To unsubscribe, e-mail: dev-unsubscribexmlbeans.apache.org
For additional commands, e-mail: dev-helpxmlbeans.apache.org

Commented: (XMLBEANS-267) toFirstAttribute/toNextAttribute doesn't work
user name
2006-04-18 23:15:18
    [ http://issues.apache.org/jira/bro
wse/XMLBEANS-267?page=comments#action_12375008 ] 

Dmitri Colebatch commented on XMLBEANS-267:
-------------------------------------------

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.

> toFirstAttribute/toNextAttribute doesn't work
> ---------------------------------------------
>
>          Key: XMLBEANS-267
>          URL: htt
p://issues.apache.org/jira/browse/XMLBEANS-267
>      Project: XMLBeans
>         Type: Bug

>   Components: XmlObject
>     Versions: Version 2.1
>  Environment: Windows XP, Intel, Sun JRE 1.5.0_04
>     Reporter: Dmitri Colebatch

>
> Either I'm misinterpreting the expected usage of
toNextAttribute, or it simply doesn't work.  Here's my
test code:
> 	public static void main(String[] args) throws
Exception
> 	{
> 		XmlObject xml = XmlObject.Factory.parse(new
StringReader("<foo
a=\"x\"><bar>test</bar></foo
>"));
> 		XmlCursor cursor = xml.newCursor();
> 		boolean found = cursor.toFirstAttribute();
> 		System.out.println("found attribute: " +
found);
> 	}
> And it outputs:
> 	found attribute: false
> I'm assuming this is a bug as the javadoc implies this
should work.

-- 
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.atl
assian.com/software/jira


------------------------------------------------------------
---------
To unsubscribe, e-mail: dev-unsubscribexmlbeans.apache.org
For additional commands, e-mail: dev-helpxmlbeans.apache.org

[1-3]

about | contact  Other archives ( Real Estate discussion Medical topics )