xmlbeans-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Wing Yew Poon" <wp...@bea.com>
Subject RE: org.apache.xmlbeans.XmlException: Element is not valid
Date Wed, 14 Mar 2007 20:55:22 GMT
assuming that "Template.xsd" is the xsd file for your schema, you are
parsing the Template schema (thus a schema instance) rather than a
Template instance, as Jacob suspected. What you want to do is to parse
an xml instance of your schema, not the schema.
For future reference, you should post user questions to the user list
(user@xmlbeans.apache.org) rather than this list, which is for
development-related matters.
- Wing Yew


From: Ramesh Ranganathan [mailto:ramesh.xb@gmail.com] 
Sent: Wednesday, March 14, 2007 12:41 PM
To: dev@xmlbeans.apache.org
Subject: Re: org.apache.xmlbeans.XmlException: Element is not valid

Hi Jacob,

Thanks for the reply. I am new to xmlbeans. Please find the xsd I used.
<?xml version="1.0" encoding="UTF-8"?>
<schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:templ="Template"
   elementFormDefault="unqualified" attributeFormDefault="unqualified">
 <element name="Template" type="templ:TemplateType">
   <documentation>Comment describing your root element</documentation> 
 <complexType name="TemplateType">
   <element name="Block" type="templ:BlockType" minOccurs="0"
  <attribute name="Name" type="string" use="optional"/>
  <attribute name="Update" type="string" use="optional"/>
  <attribute name="MinPaperSize" type="string" use="optional"/> 
 <complexType name="BlockType">
   <element name="LineItem" type="templ:LineItemType" minOccurs="0"
  <attribute name="Name" type="string" use="optional"/>
  <attribute name="Type" type="string" use="optional"/>
  <attribute name="Update" type="string" use="optional"/> 
  <attribute name="MinPaperSize" type="string" use="optional"/>
 <complexType name="LineItemType">
   <extension base="string"> 
    <attribute name="Type" type="string" use="optional"/>
    <attribute name="FontName" type="string" use="optional"/>
    <attribute name="FontSize" type="int" use="optional"/> 
    <attribute name="Bold" type="templ:YesNoType" use="optional"/>
    <attribute name="Italic" type="templ:YesNoType" use="optional"/>
    <attribute name="Alignment" type="templ:AlignmentType"
    <attribute name="Underline" type="templ:YesNoType"/>
 <simpleType name="YesNoType">
  <restriction base="string"> 
   <maxLength value="1"/>
   <pattern value="[Y|N]"/>
 <simpleType name="AlignmentType">
  <restriction base="string"> 
   <maxLength value="1"/>
   <pattern value="[L|C|R]"/>
I generated the jar using scomp.
The code is  like this
        TemplateDocument poDoc = null;
        File xsdFile = new File("Template.xsd");
            // Bind the incoming XML to an XMLBeans type.
            poDoc = TemplateDocument.Factory.parse (xsdFile);
        } catch (XmlException e)
        } catch (IOException e)

Ramesh Kumar.R

On 3/14/07, Jacob Danner <jacob.danner@gmail.com> wrote: 

	Hi Ramesh,
	This looks like it might be an expected error.
	My guess is that when you call:
	you are passing content that starts with
	<xsd:schema ... />
	rather than
	<Template ... />
	Can you confirm this is the case?
	On 3/14/07, Ramesh Ranganathan < ramesh.xb@gmail.com> wrote:
	> Hi,
	> I am getting the following exception when I try to run my
	> C:\Projects\SRS\Programs\xmlbeans\EasyPO>java Template 
	> org.apache.xmlbeans.XmlException: Element
	> schema@http://www.w3.org/2001/XMLSchema is not a valid
	> Template@Template document or a valid substitution.
	>         at
	>         at
	> org.apache.xmlbeans.impl.store.Locale.parseToXmlObject
	> (Locale.java:1273)
	>         at 
	>         at
	>         at
	>         at template.TemplateDocument$Factory.parse(Unknown
	> Source)
	>         at Template.main(Template.java :15)
	> Exception in thread "main" java.lang.NullPointerException
	>         at Template.main(Template.java:23)
	> Please help me on this.
	> Regards,
	> Ramesh Kumar.R
	To unsubscribe, e-mail: dev-unsubscribe@xmlbeans.apache.org
	For additional commands, e-mail: dev-help@xmlbeans.apache.org

Notice:  This email message, together with any attachments, may contain
information  of  BEA Systems,  Inc.,  its subsidiaries  and  affiliated
entities,  that may be confidential,  proprietary,  copyrighted  and/or
legally privileged, and is intended solely for the use of the individual
or entity named in this message. If you are not the intended recipient,
and have received this message in error, please immediately return this
by email and then delete it.

View raw message