xmlbeans-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ramesh Ranganathan" <ramesh...@gmail.com>
Subject Re: org.apache.xmlbeans.XmlException: Element is not valid
Date Wed, 14 Mar 2007 19:41:22 GMT
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"
targetNamespace="Template"
   elementFormDefault="unqualified" attributeFormDefault="unqualified">
 <element name="Template" type="templ:TemplateType">
  <annotation>
   <documentation>Comment describing your root element</documentation>
  </annotation>
 </element>
 <complexType name="TemplateType">
  <sequence>
   <element name="Block" type="templ:BlockType" minOccurs="0"
maxOccurs="unbounded"/>
  </sequence>
  <attribute name="Name" type="string" use="optional"/>
  <attribute name="Update" type="string" use="optional"/>
  <attribute name="MinPaperSize" type="string" use="optional"/>
 </complexType>
 <complexType name="BlockType">
  <sequence>
   <element name="LineItem" type="templ:LineItemType" minOccurs="0"
maxOccurs="unbounded"/>
  </sequence>
  <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>
 <complexType name="LineItemType">
  <simpleContent>
   <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" use="optional"/>
    <attribute name="Underline" type="templ:YesNoType"/>
   </extension>
  </simpleContent>
 </complexType>
 <simpleType name="YesNoType">
  <restriction base="string">
   <maxLength value="1"/>
   <pattern value="[Y|N]"/>
  </restriction>
 </simpleType>
 <simpleType name="AlignmentType">
  <restriction base="string">
   <maxLength value="1"/>
   <pattern value="[L|C|R]"/>
  </restriction>
 </simpleType>
</schema>

I generated the jar using scomp.

The code is  like this

        TemplateDocument poDoc = null;
        File xsdFile = new File("Template.xsd");
        try
        {
            // Bind the incoming XML to an XMLBeans type.
            poDoc = TemplateDocument.Factory.parse(xsdFile);
        } catch (XmlException e)
        {
            e.printStackTrace();
        } catch (IOException e)
        {
            e.printStackTrace();
        }


Regards,
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:
>
> TemplateDocument.Factory.parse()
>
> you are passing content that starts with
> <xsd:schema ... />
> rather than
> <Template ... />
>
> Can you confirm this is the case?
>
> -Jacobd
> On 3/14/07, Ramesh Ranganathan <ramesh.xb@gmail.com> wrote:
> > Hi,
> >
> > I am getting the following exception when I try to run my program.
> >
> > 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
> > org.apache.xmlbeans.impl.store.Locale.autoTypeDocument(Locale.java:322)
> >         at
> > org.apache.xmlbeans.impl.store.Locale.parseToXmlObject
> > (Locale.java:1273)
> >         at
> > org.apache.xmlbeans.impl.store.Locale.parseToXmlObject(Locale.java:1257)
> >         at
> > org.apache.xmlbeans.impl.schema.SchemaTypeLoaderBase.parse(
> SchemaTypeLoaderBase.java:345)
> >         at
> > org.apache.xmlbeans.impl.schema.SchemaTypeLoaderBase.parse(
> SchemaTypeLoaderBase.java:252)
> >         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
>
>

Mime
View raw message