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"?> 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 J 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] 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, Second, <?xml version="1.0"
encoding="UTF-8"?> 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, |
Title: NEED XMLBEANS HELP!!!
- NEED XMLBEANS HELP!!! Green, Jason M.
- RE: NEED XMLBEANS HELP!!! Yana Kadiyska
- RE: NEED XMLBEANS HELP!!! Green, Jason M.
- RE: NEED XMLBEANS HELP!!! Green, Jason M.
- RE: NEED XMLBEANS HELP!!! Yana Kadiyska
- RE: NEED XMLBEANS HELP!!! Green, Jason M.
- Re: NEED XMLBEANS HELP!!! Robin Sander
- RE: NEED XMLBEANS HELP!!! Green, Jason M.
- RE: NEED XMLBEANS HELP!!! Green, Jason M.
- RE: NEED XMLBEANS HELP!!! Green, Jason M.
- RE: NEED XMLBEANS HELP!!! Radu Preotiuc-Pietro
- RE: NEED XMLBEANS HELP!!! Green, Jason M.
- RE: NEED XMLBEANS HELP!!! Don Stewart
- RE: NEED XMLBEANS HELP!!! Green, Jason M.