Actually, 
Let me rephrase the question:
   if I am reading in a bunch of documents that I am trying to parse.
Not all of them will have the same data fields filled in.  How will I be
able to still parse without getting the nullpointer exception if a
particular field is blank? 

-----Original Message-----
From: Robin Sander [mailto:[EMAIL PROTECTED] 
Sent: Thursday, September 29, 2005 11:31 AM
To: dev@xmlbeans.apache.org
Subject: Re: NEED XMLBEANS HELP!!!


Hello,

as far as I can see you schema doesn't define a namespace, so how should
XMLBeans know which schema to use?
Try to specifiy a namespace or use the special 'noNamespace'
namespace in your XML instance.

Robin.


Green, Jason M. wrote:
> yana,
>   let me clarify.  I was able to validate the schema using a netbeans 
> utility.  i was only able to validate the xml document using a website

> so i could pass in the schema to validate against.  it still returns a

> false when trying to validate using pc.validate() (see code in my 
> previous post about what variable pc is).
> In response to using the document type to parse...
> I have a MDADocument class but i don't know if i can access the 
> planningcontextheadertype through that.  i will dig a bit deeper to 
> see if i can find it.
> Jason
> 
> ________________________________
> 
> From: Yana Kadiyska [mailto:[EMAIL PROTECTED]
> Sent: Thursday, September 29, 2005 11:09 AM
> To: dev@xmlbeans.apache.org
> Subject: RE: NEED XMLBEANS HELP!!!
> 
> 
> 
> You should be using the document type to parse a document, i.e.
> PlanningContextHeaderTypeDocument.Factory.parse(inputFile); instead of

> what you have (the type of the root element). are you saying that 
> calling pc.validate() returns true after your call - that would be 
> concerning...
> 
> If that doesn't solve your issue, let me know - I understand that you 
> might not be free to share the whole schema, but we should be able to 
> figure it out based on what you sent.
> 
>  
> 
> -Yana
> 
>  
> 
> ________________________________
> 
> From: Green, Jason M. [mailto:[EMAIL PROTECTED]
> Sent: Thursday, September 29, 2005 6:28 AM
> To: dev@xmlbeans.apache.org
> Subject: RE: NEED XMLBEANS HELP!!!
> 
>  
> 
> Okay,
> 
>    I have gotten the updated schema and i can validate that.  I do 
> know that if i try to validate the xml vs the standards it fails.  but

> if i try to validate based against the schema it validates fine.  I 
> will give you a portion of the schema (enough that it should be clear 
> if i am doing something wrong)
> 
>  
> 
> <?xml version="1.0" encoding="UTF-8"?> <xs:schema 
> xmlns:xs="http://www.w3.org/2001/XMLSchema";
> elementFormDefault="qualified" attributeFormDefault="unqualified">
> 
> <xs:complexType name="PlanningContextHeaderType">
>     <xs:annotation>
>        <xs:documentation>Complex Type containing the planning context 
> information for a document.</xs:documentation>
> 
>     </xs:annotation>
>     <xs:element name="OPLAN">
>         <xs:complexType>
>              <xs:sequence>
>                   <xs:element name="planId" type="xs:string"/>
>                   <xs:element name="name" type="xs:string"/>
>                   <xs:element name="aor" type="xs:string"
> minOccurs="0"/>
>                   <xs:element name="aorShape"
> type="AbsoluteLocationType" minOccurs="0"/>
>              </xs:sequence>
>         </xs:complexType>
>    </xs:element>
>  </xs:complexType>
> 
> </xs:schema>
> 
>  
> 
>  
> 
> Here's my code again:
> 
>  
> 
> import java.io.File;
> import java.io.IOException;
> import noNamespace.*;
> 
>  
> 
> public class parse
> {
>     
>     public static void main(String[] args)
>     {
>         try
>         {
>             String filePath = "C:\\2.xml";
>             File inputFile = new File(filePath);
> 
>             PlanningContextHeaderType pc = 
> PlanningContextHeaderType.Factory.parse(inputFile);
>             PlanningContextHeaderType.OPLAN oplan = pc.getOPLAN();
>             System.out.println(oplan.getName());
> 
>         }
> 
>         catch(org.apache.xmlbeans.XmlException e)
>         {
>             System.out.println(e.toString());
>         }
>         catch(IOException e1)
>         {
>             System.out.println(e1.toString());
>         }
> 
>  
> 
>     }
> 
> }
> 
>  
> 
> and here is the portion of the xml document
> 
> <?xml version="1.0" encoding="UTF-8"?> <MDADocument>
>         <defenseDesignDocument> 
>         <OPLAN> 
>                 <planId>9151314447111817754</planId> 
>                 <name>Venezuela</name> 
>         </OPLAN> 
>         </defenseDesignDocument>
> </MDADocument>
> 
> So does anyone know why am i getting the null pointer exception when i

> print out the oplan name?
> 
>  
> 
> Jason
> 
> ________________________________
> 
> From: Yana Kadiyska [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, September 28, 2005 2:09 PM
> To: dev@xmlbeans.apache.org
> Subject: RE: NEED XMLBEANS HELP!!!
> 
> People do exist on this mailing list :-)
> 
>  
> 
> I will try to address the second part of your email.
> 
>  
> 
> Have you tried calling the validate method with an error listener 
> after you parse in the instance? I think the code you have should work

> (and I'm saying that without seeing the schema you have) in theory. 
> The thing that I'm guessing is that the instance is somehow not valid,

> so OPLAN element is not recognized as such because it's in a different

> namespace than the schema requires it to be in (I'm assuming that the 
> NPE occurs on oplan.getName() ).
> 
>  
> 
> Sorry if this is not helpful, that's the best I can do without looking

> at the actual schema.
> 
>  
> 
> ________________________________
> 
> From: Green, Jason M. [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, September 28, 2005 11:01 AM
> To: dev@xmlbeans.apache.org
> Subject: NEED XMLBEANS HELP!!!
> 
>  
> 
> If anyone is out there listening.... 
> 
> I just got an extensive xml schema that I used xmlbeans to create a 
> jar with.  The large number of files confuses me, but that isn't the 
> basis of my email.
> 
> First,
> I have two sections of my schema that are groups and not the 
> complex/simple types.  How do I access them??  All I see are the xsb 
> files that are of the same name as the group, but no class files.
> 
> Second, 
>   I try to parse the xml doc w/ a portion that I thought worked, but 
> when I run it, I get a null pointer exception.
> This is the code: 
> PlanningContextHeaderType planContext = 
> PlanningContextHeaderType.Factory.parse(inputFile);
>             PlanningContextHeaderType.OPLAN oplan = 
> planContext.getOPLAN();
>             System.out.println(oplan.getName());
> And here is the abbreviated xml: 
> 
> <?xml version="1.0" encoding="UTF-8"?> <MDADocument>
>         <defenseDesignDocument> 
>         <OPLAN> 
>                 <planId>9151314447111817754</planId> 
>                 <name>Venezuela</name> 
>         </OPLAN> 
>         </defenseDesignDocument>
> </MDADocument>
> 
> I'll keep it at that for right now, but I have a couple more questions

> but I won't bother to write it until I hear back that people actually 
> exist in this mailing list.
> 
> Thanks,
> Jason Green
> 
> 


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