Found this link: http://markmail.org/message/4dpjccm5k5sgit3i

Hacked it a bit.  Looks very implementation dependent but it works.

Paul 
--------------
package com.corp.demo;

import java.io.File;

import noNamespace.FubarDocument;

import org.apache.xmlbeans.impl.xb.xsdschema.SchemaDocument;

public class VersionDemo
{
    /**
     * @param args
     */
    public static void main(String[] args)
    throws Exception
    {
        VersionDemo   module  = new VersionDemo();
        module.go();
    }
    private void go()
    throws Exception
    {   
        File            xmlFile  = new File("Fubar.xml");

        FubarDocument   doc      =     
                            FubarDocument.Factory.parse(xmlFile);
        if (!doc.validate())
        {   
            System.out.println("Document validation failed"); 
        }
        else
        {
            System.out.println("Document is valid");
            // get the name of the schema source file
            String source = doc.schemaType().getSourceName();
            System.out.println("schema source doc:" + source);

            // parse it
            java.io.InputStream is =     
                  VersionDemo.class.getClassLoader().getResourceAsStream
                  (
                     "schemaorg_apache_xmlbeans/src/" + source
                  );
            SchemaDocument schemadoc = SchemaDocument.Factory.parse(is);

            // get the version information
            System.out.println
            (
                  "tns: " + 
                  schemadoc.getSchema().getTargetNamespace()
            );
            System.out.println
            (
                  "version: " + 
                  schemadoc.getSchema().getVersion()
            );
        }
    }
}
--------------
 

-----Original Message-----
From: Strong.James [mailto:[email protected]] 
Sent: Thursday, June 25, 2009 1:55 PM
To: [email protected]
Subject: Getting schema attributes from generated XMLBean.

I have a question about getting schema attributes from a generated XMLBean.

I have an xsd schema that I have defined, generated the XMLBeans for, and want 
to use the generated jar in another project without separately delivering my 
source xsd. I know the source document is contained within the jar based on the 
generator. I have defined a version attribute for the schema element of my xsd. 

example.xsd......
<xs:schema targetNamespace="http://www.example.com";
       xmlns:xs="http://www.w3.org/2001/XMLSchema";
       xmlns:tns="http://www.example.com";
       elementFormDefault="qualified"
       attributeFormDefault="unqualified"
       version="0.9">
......
</xs:schema>

How can I get the value of the version attribute value of "0.9"? I'm guessing 
some of the metadata should be able to give me the schema version.

______________________________________________________________________
CONFIDENTIALITY NOTICE: This email from the State of California is for the sole 
use of the intended recipient and may contain confidential and privileged 
information. Any unauthorized review or use, including disclosure or 
distribution, is prohibited. If you are not the intended recipient, please 
contact the sender and destroy all copies of this email.

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