I am trying to use XMLBeans to access some information that is contained in my 
annotation, specifically my appinfo.  Basically I would like to retrieve the 
appinfo contents so that I can build a gui dynamically and the appinfo contains 
various information that I would like to build my gui (i.e. textbox, size, 
display name, etc...)   In the code below schemaType.getAnnotation is empty.   

import howdy.PurchaseOrderDocument;
import org.apache.xmlbeans.XmlObject;
import org.apache.xmlbeans.SchemaAnnotation;
import org.apache.xmlbeans.SchemaType;

public class HtmlBuilder {

    public HtmlBuilder() {
        PurchaseOrderDocument po = PurchaseOrderDocument.Factory.newInstance();
        po.addComment("Hello");

      
        SchemaType schemaType = po.schemaType();
        if (schemaType != null) {

            if (schemaType.getAnnotation() != null) {
                XmlObject[] appInfo 
=po.schemaType().getAnnotation().getApplicationInformation();
                SchemaAnnotation.Attribute[] attrs = 
po.schemaType().getAnnotation().getAttributes();
                for (int i = 0; i < attrs.length; i++) {
                    SchemaAnnotation.Attribute attr = attrs[i];
                    System.out.println("aa" + attr.getName());
                    System.out.println("attr.getValue() = " + attr.getValue());
                }
            }
        }

    }

    public static void main(String[] args) {
        HtmlBuilder hh = new HtmlBuilder();
    }
}


Is this possible ?  Does anybody have any examples.

Thanks,

Ian


Here is my Schema file:
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"; 
xmlns:app="http://howdy/guiextensions";>
        <xsd:annotation>
                <xsd:documentation xml:lang="en">
     Purchase order schema for Example.com.
     Copyright 2000 Example.com. All rights reserved.
    </xsd:documentation>
        </xsd:annotation>
        <xsd:element name="purchaseOrder" type="PurchaseOrderType">
            <xsd:annotation>
                    <xsd:appinfo>
                            <app:guiDisplayName>Purchase Order
                            </app:guiDisplayName>
                    </xsd:appinfo>
            </xsd:annotation>
        </xsd:element>
        
        <xsd:element name="comment" type="xsd:string">
            <xsd:annotation>
                    <xsd:appinfo>
                            <app:guiDisplayName>Comment
                            </app:guiDisplayName>
                    </xsd:appinfo>
            </xsd:annotation>
        </xsd:element>
        <xsd:complexType name="PurchaseOrderType">
                <xsd:sequence>
                        <xsd:element name="shipTo" type="USAddress"/>
                        <xsd:element name="billTo" type="USAddress"/>
                        <xsd:element ref="comment" minOccurs="0"/>
                        <xsd:element name="items" type="Items"/>
                </xsd:sequence>
                <xsd:attribute name="orderDate" type="xsd:date"/>
        </xsd:complexType>
        <xsd:complexType name="USAddress">
                <xsd:sequence>
                        <xsd:element name="name" type="xsd:string"/>
                        <xsd:element name="street" type="xsd:string"/>
                        <xsd:element name="city" type="xsd:string"/>
                        <xsd:element name="state" type="xsd:string"/>
                        <xsd:element name="zip" type="xsd:decimal"/>
                </xsd:sequence>
                <xsd:attribute name="country" type="xsd:NMTOKEN" fixed="US"/>
        </xsd:complexType>
        <xsd:complexType name="Items">
                <xsd:sequence>
                        <xsd:element name="item" minOccurs="0" 
maxOccurs="unbounded">
                                <xsd:complexType>
                                        <xsd:sequence>
                                                <xsd:element name="productName" 
type="xsd:string"/>
                                                <xsd:element name="quantity">
                                                        <xsd:simpleType>
                                                                
<xsd:restriction base="xsd:positiveInteger">
                                                                        
<xsd:maxExclusive value="100"/>
                                                                
</xsd:restriction>
                                                        </xsd:simpleType>
                                                </xsd:element>
                                                <xsd:element name="USPrice" 
type="xsd:decimal"/>
                                                <xsd:element ref="comment" 
minOccurs="0"/>
                                                <xsd:element name="shipDate" 
type="xsd:date" minOccurs="0"/>
                                        </xsd:sequence>
                                        <xsd:attribute name="partNum" 
type="SKU" use="required"/>
                                </xsd:complexType>
                        </xsd:element>
                </xsd:sequence>
        </xsd:complexType>
        <!-- Stock Keeping Unit, a code for identifying products -->
        <xsd:simpleType name="SKU">
                <xsd:restriction base="xsd:string">
                        <xsd:pattern value="\d{3}-[A-Z]{2}"/>
                </xsd:restriction>
        </xsd:simpleType>
</xsd:schema>

Here is my guiextensions schema file:
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:gx="http://www.metasolv.com/serviceactivator/guiextensions"; 
targetNamespace="http://www.metasolv.com/serviceactivator/guiextensions"; 
xmlns:xs="http://www.w3.org/2001/XMLSchema"; elementFormDefault="qualified" 
attributeFormDefault="unqualified">
        <xs:element name="guiDisplayName" type="xs:string"/>
</xs:schema>

                Ian Butt
                Senior Software Designer, MetaSolv IP Service Activator 
                MetaSolv Software
                360 March Road
                Ottawa, ON
                Office Phone:  613-287-8182
                E-mail: [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>

                ++++++CONFIDENTIALITY NOTICE+++++ 
                The information in this email may be confidential and/or 
privileged. This email is intended to be reviewed by only the individual or 
organization named above. If you are not the intended recipient or an 
authorized representative of the intended recipient, you are hereby notified 
that any review, dissemination or copying of this email and its attachments, if 
any, or the information contained herein is prohibited. If you have received 
this email in error, please immediately notify the sender by return email and 
delete this email from your system. 


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to