Hi,

my instance was not valid.

Thank you for the Help!

Andreas

-----Ursprüngliche Nachricht-----
Von: Jacob Danner [mailto:[EMAIL PROTECTED] 
Gesendet: Freitag, 2. Mai 2008 17:49
An: user@xmlbeans.apache.org
Betreff: Re: Beginners Problem? NullPointerException from several getMethods

Hi Andreas,
You may be getting the NPEs because the document you are working with isn't 
valid. Have you tried calling validate() on it and seeing if there were errors. 
If you have an instance and a schema you can use the svalidate tool from the 
bin directory. If you want to validate programmatically there is also a sample 
for you to look at:
http://xmlbeans.apache.org/samples/Validation.html

HTH,
-jacobd

On Fri, May 2, 2008 at 4:18 AM, Weck, Andreas <[EMAIL PROTECTED]> wrote:
>
>  Hi all,
>
>  i am just a beginner with XMLBeans and i run into problem with a  
> NullPointerException.
>  I got a schema from a company and a test XML File.
>
>  The main part of the Schema (i will post here just a part of the
>  schema):
>  
> ----------------------------------------------------------------------
> --
>  ----
>  <?xml version="1.0" encoding="UTF-8"?>  <xs:schema 
> xmlns:xs="http://www.w3.org/2001/XMLSchema";
>  xmlns:abcstat="http://www.pagex.de/abc/spa";
>  xmlns:abcueb="http://www.pagex.de/abc/um";
>  xmlns:abcvend="http://www.pagex.de/abc/ve";
>  xmlns="http://www.pagex.de/zf/update";
>  targetNamespace="http://www.pagex.de/zf/update";
>  elementFormDefault="qualified" attributeFormDefault="qualified">
>   <xs:include schemaLocation="something4.xsd"/>
>   <xs:import namespace="http://www.pagex.de/abc/spa";
>  schemaLocation="abc/something1.xsd"/>
>   <xs:import namespace="http://www.pagex.de/abc/um";
>  schemaLocation="abc/something2.xsd"/>
>   <xs:import namespace="http://www.pagex.de/abc/ve";
>  schemaLocation="abc/something3.xsd"/>
>   <xs:element name="FTmitt">
>     <xs:complexType>
>       <xs:sequence>
>         <xs:element name="Mitt" type="mitt" maxOccurs="unbounded"/>
>       </xs:sequence>
>     </xs:complexType>
>   </xs:element>
>   <xs:complexType name="mitt">
>     <xs:choice>
>       <xs:element ref="abcstat:Message"/>
>       <xs:element ref="abcueb:Message"/>
>       <xs:element ref="abcvend:Message"/>
>     </xs:choice>
>   </xs:complexType>
>  </xs:schema>
>  
> ----------------------------------------------------------------------
> --
>  ----
>
>  The test.xml to parse:
>  
> ----------------------------------------------------------------------
> --
>  ----
>  <?xml version="1.0" encoding="utf-8"?>  <FTmitt 
> xmlns="http://www.pagex.de/zf/update";
>  xmlns:abc="http://www.pagex.de/abc/mitt";
>  xmlns:n1="http://www.pagex.de/zf/update";
>  xmlns:abcueb="http://www.pagex.de/abc/um";
>  xmlns:abcvend="http://www.pagex.de/abc/ve";
>  xmlns:abcstat="http://www.pagex.de/abc/spa";
>  xmlns:abcquit="http://www.pagex.de/abc/quittung";
>  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; >
>   <Mitt n1:Satznummer="004">
>     <abcstat:Message>
>                 <abc:Head>...</abc:Head>
>                 ...
>                 ...
>                 ...
>           </abcstat:Message>
>   </Mitt>
>  </FTmitt>
>  
> ----------------------------------------------------------------------
> --
>  ----
>
>  Here some test code:
>  FTmittDocument doc = FTmittDocument.Factory.parse(new  
> File("./test.xml")); Mitt choices = doc.getMitt(); mitt[] m =  
> choices.getmittArray();
>
>  This Line print me the <xml-fragment>...</xml-fragment>  
> System.out.print(m[0].getMessage().xmlText());
>
>  But this line brings me a java.lang.NullPointerException!!!
>  m[0].getMessage().getHead();
>
>  All other get-Methods who belongs to the Message-Oject bring me  
> NullPointerException too.
>
>  Have somebody a idea or a hint?
>
>  Regards,
>  Andreas
>
>
>  ---------------------------------------------------------------------
>  To unsubscribe, e-mail: [EMAIL PROTECTED]
>  For additional commands, e-mail: [EMAIL PROTECTED]
>
>



--
I'm competing in a Half-Ironman distance triathlon to raise money for the fight 
against cancer!
Please help support my efforts by going to:
http://www.active.com/donate/tntwaak/jacobd

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


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

Reply via email to