You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@xmlbeans.apache.org by Tammo Mueller <ta...@gmail.com> on 2005/05/03 01:13:42 UTC

retrieving annotations from the Schema...

Hi!
 I have a little problem when trying to retrieve the annotations from my 
xml-Schema.
 Schema snippet...
...
 <xs:element name="project">
<xs:annotation>
<xs:documentation>Project</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:sequence>
<xs:element name="name" type="xs:string">
<xs:annotation>
<xs:documentation>Name of the Project</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="description" type="xs:string">
<xs:annotation>
<xs:appinfo>Description of the Project</xs:appinfo>
</xs:annotation>
</xs:element>
...
 I'm trying to access the name element annotation via 
  SchemaLocalElement schemaElement = (SchemaLocalElement) 
projectDocument.getProject
().schemaType().getContentModel().getParticleChild(0);
System.out.println(schemaElement.getAnnotation
().getUserInformation()[0].execQuery("//xs:documentation/text()")[0])
 That gives me:
<xml-fragment>Name of the Project</xml-fragment>
 I just want 'Name of the Project'.
 How can I achieve it.
 Thanks.
 Tammo

Re: retrieving annotations from the Schema...

Posted by Tammo Mueller <ta...@gmail.com>.
Hi Sujoy,
 I see the point. But W3C XML Schema provides this kind of documentation. 
They should not be element tags but metadata describing an element tag.
I use XMLSpy 2005 and this program to generates the documentation like this.
 Regards,
 Tammo

 On 5/3/05, sujoy.banerjee@tcs.com <su...@tcs.com> wrote: 
> 
> 
> Hi, 
> I want to point out something about the schema itself.... 
> 
> <xs:element name="project">
> <xs:annotation>
> <xs:documentation>Project</xs:documentation>
> </xs:annotation>
> <xs:complexType>
> <xs:sequence> 
> <xs:element name="name" type="xs:string">
> <xs:annotation>
> <xs:documentation>Name of the Project</xs:documentation>
> </xs:annotation>
> </xs:element> 
> <xs:element name="description" type="xs:string">
> <xs:annotation>
> <xs:appinfo>Description of the Project</xs:appinfo>
> </xs:annotation>
> </xs:element> 
> ... 
> In the schema itself it is not advisable to write the data part. Here in 
> the <xs:documentation>Project</xs:documentation>, the schema compiler 
> expects something like <xs:element name="documentation" type="xs:string"
> ></xs:documentation>. Again in the case of <xs:documentation>Name of the 
> Project</xs:documentation> and <xs:appinfo>Description of the 
> Project</xs:appinfo>, the compiler expects something like 
> <xs:element name="appinfo" type="xs:string"></xs:element>. These 
> definitions may be defined globally or locally within the definition of 
> another element. 
> 
> I think rewriting the schema in this fashion would solve the value 
> retrieving problem. The data part should be in another XML where the schema 
> is referenced. 
> 
> Let me know whether it helps really? 
> 
> 
> Sujoy Banerjee
> Tata Consultancy Services Limited
> Plot B-1, Block EP & GP
> Sector - V, Salt Lake Electronics Complex
> Kolkata - 700 091,West Bengal
> India
> Mailto: sujoy.banerjee@tcs.com
> Website: http://www.tcs.com 
> 
> 
>   *Tammo Mueller <ta...@gmail.com>* 
> 
> 05/03/2005 04:43 AM   Please respond to
> user@xmlbeans.apache.org
> 
>    To
> user@xmlbeans.apache.org  cc
>   Subject
> retrieving annotations from the Schema...
>   
>  
> 
> 
> Hi! 
>  
> I have a little problem when trying to retrieve the annotations from my 
> xml-Schema. 
>  
> Schema snippet... 
> ... 
>  
> <xs:element name="project">
> <xs:annotation>
> <xs:documentation>Project</xs:documentation>
> </xs:annotation>
> <xs:complexType>
> <xs:sequence> 
> <xs:element name="name" type="xs:string">
> <xs:annotation>
> <xs:documentation>Name of the Project</xs:documentation>
> </xs:annotation>
> </xs:element> 
> <xs:element name="description" type="xs:string">
> <xs:annotation>
> <xs:appinfo>Description of the Project</xs:appinfo>
> </xs:annotation>
> </xs:element> 
> ... 
>  
> I'm trying to access the name element annotation via 
>  
> SchemaLocalElement schemaElement = (SchemaLocalElement) 
> projectDocument.getProject
> ().schemaType().getContentModel().getParticleChild(0); 
> System.out.println(schemaElement.getAnnotation
> ().getUserInformation()[0].execQuery("//xs:documentation/text()")[0]) 
>  
> That gives me: 
> <xml-fragment>Name of the Project</xml-fragment>
> 
> I just want 'Name of the Project'. 
>  
> How can I achieve it. 
>  
> Thanks. 
>  
> Tammo 
>  
>  
>  
> ForwardSourceID:NT0000B25E 
>   Notice: The information contained in this e-mail message and/or 
> attachments to it may contain confidential or privileged information. If you 
> are not the intended recipient, any dissemination, use, review, 
> distribution, printing or copying of the information contained in this 
> e-mail message and/or attachments to it are strictly prohibited. If you have 
> received this communication in error, please notify us by reply e-mail or 
> telephone and immediately and permanently delete the message and any 
> attachments. Thank you
>

Re: retrieving annotations from the Schema...

Posted by su...@tcs.com.
Hi,
I want to point out something about the schema itself....

<xs:element name="project">
  <xs:annotation>
   <xs:documentation>Project</xs:documentation>
  </xs:annotation>
  <xs:complexType>
   <xs:sequence> 
    <xs:element name="name" type="xs:string">
     <xs:annotation>
      <xs:documentation>Name of the Project</xs:documentation>
     </xs:annotation>
    </xs:element> 
    <xs:element name="description" type="xs:string">
     <xs:annotation>
      <xs:appinfo>Description of the Project</xs:appinfo>
     </xs:annotation>
    </xs:element> 
...
In the schema itself it is not advisable to write the data part. Here in 
the  <xs:documentation>Project</xs:documentation>, the schema compiler 
expects something like  <xs:element name="documentation"  type="xs:string"
></xs:documentation>. Again in the case of       <xs:documentation>Name of 
the Project</xs:documentation> and       <xs:appinfo>Description of the 
Project</xs:appinfo>, the compiler expects something like
<xs:element name="appinfo" type="xs:string"></xs:element>. These 
definitions may be defined globally or locally within the definition of 
another element.

I think rewriting the schema in this fashion would solve the value 
retrieving problem. The data part should be in another XML where the 
schema is referenced.

Let me know whether it helps really?


Sujoy Banerjee
Tata Consultancy Services Limited
Plot  B-1, Block EP & GP
Sector - V, Salt Lake Electronics Complex
Kolkata - 700 091,West Bengal
India
Mailto: sujoy.banerjee@tcs.com
Website: http://www.tcs.com



Tammo Mueller <ta...@gmail.com> 
05/03/2005 04:43 AM
Please respond to
user@xmlbeans.apache.org


To
user@xmlbeans.apache.org
cc

Subject
retrieving annotations from the Schema...






Hi!
 
I have a little problem when trying to retrieve the annotations from my 
xml-Schema.
 
Schema snippet...
...
 
<xs:element name="project">
  <xs:annotation>
   <xs:documentation>Project</xs:documentation>
  </xs:annotation>
  <xs:complexType>
   <xs:sequence> 
    <xs:element name="name" type="xs:string">
     <xs:annotation>
      <xs:documentation>Name of the Project</xs:documentation>
     </xs:annotation>
    </xs:element> 
    <xs:element name="description" type="xs:string">
     <xs:annotation>
      <xs:appinfo>Description of the Project</xs:appinfo>
     </xs:annotation>
    </xs:element> 
...
 
I'm trying to access the name element annotation via 
 
 SchemaLocalElement schemaElement = (SchemaLocalElement) 
projectDocument.getProject().schemaType().getContentModel().getParticleChild(0);
System.out.println(schemaElement.getAnnotation().getUserInformation()[0].execQuery("//xs:documentation/text()")[0])
 
That gives me:
<xml-fragment>Name of the Project</xml-fragment>
 
I just want 'Name of the Project'.
 
How can I achieve it.
 
Thanks.
 
Tammo
 
 
 
ForwardSourceID:NT0000B25E 


Notice: The information contained in this e-mail message and/or attachments to it may contain confidential or privileged information.   If you are not the intended recipient, any dissemination, use, review, distribution, printing or copying of the information contained in this e-mail message and/or attachments to it are strictly prohibited.   If you have received this communication in error, please notify us by reply e-mail or telephone and immediately and permanently delete the message and any attachments.  Thank you