You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xmlbeans.apache.org by "Lawrence Jones (JIRA)" <xm...@xml.apache.org> on 2005/07/07 19:59:13 UTC

[jira] Assigned: (XMLBEANS-161) Unable to cast from cursor.getObject to type generated from schema.

     [ http://issues.apache.org/jira/browse/XMLBEANS-161?page=all ]

Lawrence Jones reassigned XMLBEANS-161:
---------------------------------------

    Assign To: Yana Kadiyska

> Unable to cast from cursor.getObject to type generated from schema.
> -------------------------------------------------------------------
>
>          Key: XMLBEANS-161
>          URL: http://issues.apache.org/jira/browse/XMLBEANS-161
>      Project: XMLBeans
>         Type: Bug
>   Components: Cursor
>     Versions: Version 2 Beta 1
>     Reporter: Steve Traut
>     Assignee: Yana Kadiyska
>  Attachments: TestCode.zip
>
> When retrieving XML using cursor.getObject, it appears not possible to cast the returned XML to a specific schema type even when the XML conforms to the schema. The following snippet attempts to retrieve elements using XPath, use a cursor to reach a returned element's parent, then cast the parent XML to a schema type. But the cast fails.
> Code attached.
>         private String m_namespaceUri = "http://xmlbeans.apache.org/samples/any";
>         String namespaceDecl = "declare namespace any='" + m_namespaceUri
>                 + "'; ";
>         XmlObject[] someElements = rootDoc.selectPath(namespaceDecl
>                 + "$this//any:stringelement");
>         for (int i = 0; i < someElements.length; i++)
>         {
>             XmlCursor editCursor = someElements[i].newCursor();
>             editCursor.toParent();
>             ListOfStrings stringList = null;
>             try
>             {
>                 // Shouldn't this cast work? //
>                 stringList = (ListOfStrings) editCursor.getObject();
>                 System.out.println(stringList);
>             } catch (ClassCastException cce)
>             {
>                 continue;
>             }            
>         }

-- 
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