Real quick reply, so forgive me if I am missing something specific. What happens when you try to validate your type? I'm going to imagine you get a couple of errors.
I think you should try using something like: MetadataDocument doc = MetadataDocument.Factory.parse(new ...) The differences between Types and Document are discussed in the getting started docs. Let the list know if that takes care of it or if you need further help, -jacobd On Thu, Jan 8, 2009 at 2:00 PM, Wm.A.Stafford <[email protected]> wrote: > I'm a novice user of XmlBeans. I've used it successfully to parse several > simple schemas but when I moved on to a more complicated schema I quickly > came to a screeching halt. > > Here is a segment of the schema I am working with: > > <xsd:element name="metadata" type="metadataResultType"> > <xsd:annotation> > <xsd:documentation>Global element to validate external metadata > XMLfiles.</xsd:documentation> > </xsd:annotation> > </xsd:element> > <xsd:complexType name="metadataResultType"> > <xsd:annotation> > <xsd:documentation>Format of metadata operation > result.</xsd:documentation> > </xsd:annotation> > <xsd:sequence> > <xsd:element ref="dc:title"> > <xsd:annotation> > <xsd:documentation>The name of this > service</xsd:documentation> > </xsd:annotation> > </xsd:element> > <xsd:element ref="dc:type"> > <xsd:annotation> > <xsd:documentation>The nature or genre of the > content</xsd:documentation> > </xsd:annotation> > </xsd:element> > ... lots more elements > </xsd:sequence> > </xsd:complexType> > > Here is a segment of Java that XMLBeans generated. > > /** > * An XML metadataResultType(@http://rs.tdwg.org/tapir/1.0). > * > * This is a complex type. > */ > public interface MetadataResultType extends org.apache.xmlbeans.XmlObject > { > public static final org.apache.xmlbeans.SchemaType type = > (org.apache.xmlbeans.SchemaType) > > org.apache.xmlbeans.XmlBeans.typeSystemForClassLoader(MetadataResultType.class.getClassLoader(), > "schemaorg_apache_xmlbeans.system.sC4F7BF7BC2573C292B659C414C97BA9A").resolveHandle("metadataresulttype5083type"); > /** > * Gets the "title" element > */ > org.purl.dc.elements.x11.SimpleLiteral getTitle(); > > Here is a segment of java to extract the title from the server response. > MetadataResultType doc = MetadataResultType.Factory.parse(new URL( > server_url )); > System.out.println("title=" + doc.getTitle() ); > System.out.println("doc=" + doc.toString()) ; > > This is the output of the code fragment. > title=null > > doc=<response xsi:schemaLocation="http://rs.tdwg.org/tapir/1.0 > http://rs.tdwg.org/tapir/1.0/schema/tapir.xsd" > xmlns="http://rs.tdwg.org/tapir/1.0" > xmlns:dc="http://purl.org/dc/elements/1.1/" > xmlns:dct="http://purl.org/dc/terms/" > xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" > xmlns:vcard="http://www.w3.org/2001/vcard-rdf/3.0#" > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> > <header>.. contents removed...</header> > <metadata xml:lang="en"> > <dc:title xml:lang="en">Photo-identification Library</dc:title> > <dc:type>http://purl.org/dc/dcmitype/Service</dc:type> > ... lots more elements removed > </metadata> > </response> > > I would like to get the title, type and ... lots more elements from the > response. My first attempt, > calling getTitle(), seemed not only the obvious but the only choice. > How to I get at title and the rest of the metadata sequence and why does > getTitle() return null? > > Thanks for any help or advice, > -=beeky > > --------------------------------------------------------------------- > 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]

