Thanks Lawrence that certainly got me headed in the right direction. If this
is my schema below, I have figured out how to get the main element's app info
but how do I go about getting the complex type's annotations ? It seems like
you can do it fine for global elements since each global element gets mapped
into a Document class with a type member variable, but complex types seem not
to follow this.
Thanks again,
Ian
public class HtmlBuilder {
public HtmlBuilder() {
DiaDocument dia = DiaDocument.Factory.newInstance();
Dia diaObject = dia.addNewDia();
diaObject.addLanPrefixList("Lan");
diaObject.addWanPrefixList("Wan");
SchemaAnnotation ann = ((SchemaLocalElement)
DiaDocument.type.getContentModel()).getAnnotation();
XmlObject[] appInfo = ann.getApplicationInformation();
for (int i = 0; i < appInfo.length; i++) {
GuiDocument gui = null;
try {
gui = GuiDocument.Factory.parse(appInfo[i].toString());
} catch (XmlException e) {
e.printStackTrace();
}
System.out.println("gui.getGui().getGuiDisplayName() = " +
gui.getGui().getDisplayName());
System.out.println("gui.getGui().getFieldName() = " +
gui.getGui().getFieldName());
}
String[] prefixes = dia.getDia().getLanPrefixListArray();
for (int i = 0; i < prefixes.length; i++) {
String prefix = prefixes[i];
}
}
public static void main(String[] args) {
HtmlBuilder hh = new HtmlBuilder();
}
}
<xs:schema targetNamespace="http://newservice" xmlns:app="http://guiextensions"
xmlns:nser="http://newservice" xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:complexType name="Dia">
<xs:sequence>
<xs:element name="lanPrefixList" type="xs:string"
minOccurs="0" maxOccurs="unbounded">
<xs:annotation>
<xs:appinfo>
<app:gui>
<app:displayName>Lan
Prefix List</app:displayName>
<app:fieldName>lPrefixList</app:fieldName>
</app:gui>
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element name="wanPrefixList" type="xs:string"
minOccurs="0" maxOccurs="unbounded">
<xs:annotation>
<xs:appinfo>
<app:gui>
<app:displayName>Wan
Prefix List</app:displayName>
<app:fieldName>wPrefixList</app:fieldName>
</app:gui>
</xs:appinfo>
</xs:annotation>
</xs:element>
</xs:sequence>
</xs:complexType>
<xs:element name="dia" type="nser:Dia">
<xs:annotation>
<xs:appinfo>
<app:gui>
<app:displayName>Dia</app:displayName>
<app:fieldName>DiaField</app:fieldName>
</app:gui>
</xs:appinfo>
</xs:annotation>
</xs:element>
</xs:schema>
-----Original Message-----
From: Lawrence Jones [mailto:[EMAIL PROTECTED]
Sent: Friday, August 26, 2005 4:47 PM
To: [email protected]; [email protected]
Subject: RE: Trying to use XMLBeans 2.0 and appinfo
Hi Ian
I think the following thread the user mailing list on 7/19/05 -
http://mail-archives.apache.org/mod_mbox/xmlbeans-user/200507.mbox/%3c4B
[EMAIL PROTECTED] will
help you.
Cheers,
Lawrence
> -----Original Message-----
> From: Butt, Ian [mailto:[EMAIL PROTECTED]
> Sent: Friday, August 26, 2005 1:33 PM
> To: [email protected]; [email protected]
> Subject: Trying to use XMLBeans 2.0 and appinfo
>
> 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]
---------------------------------------------------------------------
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]