Can you in the meantime post the actual NPE that you are getting with
(at least a few levels of) the stacktrace? I don't think I have ever
seen it in this thread. It's not clear to me where is the null coming
from. Depending on that, it may be a legitimate NPE or not...

Radu

-----Original Message-----
From: Green, Jason M. [mailto:[EMAIL PROTECTED] 
Sent: Monday, October 03, 2005 6:59 AM
To: dev@xmlbeans.apache.org
Subject: RE: NEED XMLBEANS HELP!!!

Don,
  since you have raised a good point in your last email, I will only ask
one question in response to your 3rd point.
Does the validate function only validate the schema or does it validate
the values in the class?  I'm unclear on how it works. 

I will talk to the people who came up with the schema, and at the very
least look at the portions of the code where I get the NPE and see if it
has a minOccurs 0.  If it doesn't, then I will try to get that fixed.
If it does, should I really be getting a NPE?
Jason

-----Original Message-----
From: Don Stewart [mailto:[EMAIL PROTECTED] 
Sent: Monday, October 03, 2005 9:46 AM
To: dev@xmlbeans.apache.org
Subject: RE: NEED XMLBEANS HELP!!!

Jason,

3 points.

1)

It is an inner portion of PlanningContextHeaderType that I changed :-

                </xs:annotation>
                <xs:element name="OPLAN">
                        <xs:complexType>

To 

                </xs:annotation>
                <xs:sequence>
                        <xs:element name="OPLAN">
                                <xs:complexType>


I have never personnally seen the NPE from Xmlbeans in the situation you
are in.


2)

Also have you looked at using :-

isNil

public boolean isNil()

    True if the value is nil. Note that in order to be nil, the value
must be in an element, and the element containing the value must be
marked as nillable in the schema.


3)

One final point after the line 

PlanningContextHeaderType planContext =
PlanningContextHeaderType.Factory.parse(inputFile);
You do not seem to be checking planContext.validate() to ensure you get
true i.e. valid input to continue.


Cheers

Don
-----Original Message-----
From: Green, Jason M. [mailto:[EMAIL PROTECTED]
Sent: 03 October 2005 14:24
To: dev@xmlbeans.apache.org
Subject: RE: NEED XMLBEANS HELP!!!

Don,
  the schema that I had shown was only a portion and did not have all
the outer portions shown.  I will ask the owners of the schema about the
nillable="true" portion.  Why can't that return null when I try to
access it instead of throwing the exception?
Jason 

-----Original Message-----
From: Don Stewart [mailto:[EMAIL PROTECTED]
Sent: Monday, October 03, 2005 9:19 AM
To: dev@xmlbeans.apache.org
Subject: RE: NEED XMLBEANS HELP!!!

Jason,

Looking at the schema in the document are you sure it is valid ?

You have an element <xs:element name="OPLAN"> within a <xs:complexType
name="PlanningContextHeaderType"> Not within a <sequence> | <group> |
<all> | <choice> .

So is it not the case that 

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

Should in fact be:- 

<?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:sequence>
                        <xs:element name="OPLAN">
                                <xs:complexType>
                                        <xs:sequence>
                                                <xs:element
name="planId" type="xs:string"/>
                                                <xs:element name="name"
type="xs:string" nillable="true"/>
                                                <xs:element name="aor"
type="xs:string" minOccurs="0"/>
                                                <!--
<xs:element name="aorShape" type="AbsoluteLocationType" minOccurs="0"/>
-->
                                        </xs:sequence>
                                </xs:complexType>
                        </xs:element>
                </xs:sequence>
        </xs:complexType>
</xs:schema>


Also the elements that could be null should have be nillable="true".

Regards

Don

-----Original Message-----
From: Green, Jason M. [mailto:[EMAIL PROTECTED]
Sent: 03 October 2005 13:36
To: dev@xmlbeans.apache.org
Subject: RE: NEED XMLBEANS HELP!!!

Radu,
  I'm not quite sure what you mean by parsing.  I'm under the impression
that is what I was doing.  I will show you the code I am using and you
can let me know if I am doing it wrong?  I do realize that there should
be some error checking, but I thought I would be able to print out a
null value without error.  Please correct me if I am wrong.  Here is my
code:

public static void main(String[] args)
    {        
        String filePath = "C:\\Plans\\2.xml";
        File inputFile = new File(filePath);
        try
        {   
            MDADocumentDocument1 doc =
MDADocumentDocument1.Factory.parse(inputFile);
            MDADocumentDocument1.MDADocument gdoc =
doc.getMDADocument();
            AnalysisViewType aView = gdoc.getDefenseDesignDocument();
            
            PlanningContextHeaderType planContext =
aView.getPlanningContextHeader();
            PlanningContextHeaderType.OPLAN oplan =
planContext.getOPLAN();
            oplan.getName();
    
        }
        catch(org.apache.xmlbeans.XmlException e)
        {
            System.out.println(e.toString());
        }
        catch(IOException e1)
        {
            System.out.println(e1.toString());
        }
    }

It looks pretty simple.  I know that I can't / won't put a try catch
around every piece of data I'm trying to access.
Thanks
Jason 

-----Original Message-----
From: Radu Preotiuc-Pietro [mailto:[EMAIL PROTECTED]
Sent: Thursday, September 29, 2005 8:27 PM
To: dev@xmlbeans.apache.org
Subject: RE: NEED XMLBEANS HELP!!!

This is not a question of parsing, it's a question of how you query your
objects after parsing is done. In your example, you got the NPE while
calling oplan.getName(); all you have to do is parse (no NPE will be
thrown here regardless of the Schema and document), then use your
planContext object as you would any other Java object, taking care that
some of the fields may be null.

Radu

-----Original Message-----
From: Green, Jason M. [mailto:[EMAIL PROTECTED]
Sent: Thursday, September 29, 2005 10:35 AM
To: dev@xmlbeans.apache.org
Subject: RE: NEED XMLBEANS HELP!!!

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]


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


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


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


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

Reply via email to