I found an old thread between Michael and myself on basically this same
issue:

http://old.nabble.com/Accessing-non-schema-attributes-via-XSModel-td29557367.html

And at the time, evidently I *was* able to read at least the synthetic
annotations. So I guess that works in at least some circumstances.

The big difference between what I was doing then and what we're doing now
is that I was using Xerces to parse the actual XML, in addition to loading
the schemas. So the XSElementDeclaration was handled to
handleElementPSVI(). In our new code, though (part of a larger product),
the parsing is handled externally to Xerces, so we're looking up the
XSElementDeclaration with XSModel::getElementDeclaration(). Could that be
making a difference?

Ceej
aka Chris Hillery

On Mon, Feb 20, 2012 at 2:33 AM, Chris Hillery <c...@lambda.nu> wrote:

> Hi,
>
> I've been working on this problem with Luis. Unfortunately it doesn't seem
> that Xerces does what we'd expect in this case. In all cases, calling
> getAnnotation() on the XSElementDeclaration returns NULL. I've tried
> enabling fgXercesGenerateSyntheticAnnotations, and also tried enabling
> fgXercesValidateAnnotations just in case. I've verified that
> fgIgnoreAnnotations is false. No luck.
>
> The other problem we have is, in addition to the extra non-schema
> attributes, we also want to read the normal annotations on the schema. In
> the example Luis provided, there's an <xs:annotation> element on the
> <xs:complexType> for this global element Employee. But, as above,
> getAnnotation() on the XSElementDeclaration returns NULL. In this case, I
> would think that makes sense, as the annotation is on the complex type, not
> the element itself. However, there doesn't seem to be any getAnnotation()
> method on XSTypeDefinition, which is the only reasonable path I can see.
>
> Thanks,
> Ceej
> aka Chris Hillery
>
>
>
> On Sun, Feb 5, 2012 at 8:56 PM, Michael Glavassevich 
> <mrgla...@ca.ibm.com>wrote:
>
>> Hi Luis,
>>
>> Luis Rodriguez <kur...@gmail.com> wrote on 02/02/2012 12:21:29 PM:
>>
>> > Hi Michael,
>> >
>> > What API should I use to retrieve such data?
>> > XSElementDeclaration::getAnnotation()?
>>
>> Yes, I would expect you'd find it there.
>>
>> > Is there any documentation out
>> > there? or any book I can get to understand how this works?
>>
>> Xerces' XML Schema API is documented here:
>> http://www.w3.org/Submission/2004/SUBM-xmlschema-api-20040122/
>>
>> > Thanks,
>> > Luis.
>> >
>> > 2012/2/1 Michael Glavassevich <mrgla...@ca.ibm.com>
>> >
>> > > Hi Luis,
>> > >
>> > > Have you tried enabling the generate-synthetic-annotations [1]
>> feature?
>> > > That should generate an XSAnnotation for each schema component (e.g.
>> > > XSElementDeclaration) with non-schema attributes but no xs:annotation
>> > > children.
>> > >
>> > > Thanks.
>> > >
>> > > [1]
>> > >
>> > > http://xerces.apache.org/xerces-c/program-
>> > sax2-3.html#GenerateSyntheticAnnotations
>> > >
>> > > Michael Glavassevich
>> > > XML Technologies and WAS Development
>> > > IBM Toronto Lab
>> > > E-mail: mrgla...@ca.ibm.com
>> > > E-mail: mrgla...@apache.org
>> > >
>> > > Luis Rodriguez <kur...@gmail.com> wrote on 02/01/2012 06:41:14 PM:
>> > >
>> > > > Hi everyone!
>> > > >
>> > > > I have a problem trying to get some information from a Schema file.
>> I
>> got
>> > > > this schema:
>> > > >
>> > > > <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema";
>> > > >             xmlns:csx="http://xmlns.oracle.com/2004/CSX";
>> > > >             targetNamespace="http://www.opencsx.org/schema";
>> > > >             elementFormDefault="qualified">
>> > > > <xsd:element name="Employee" csx:propertyID="1234">
>> > > >   <xsd:complexType>
>> > > >     <xsd:annotation>
>> > > >       <xsd:appinfo>
>> > > >         <csx:kidList sequential="true">
>> > > >           <csx:kid propertyID="3456" kidNum="1"/>
>> > > >           <csx:kid propertyID="3457" kidNum="2"/>
>> > > >         </csx:kidList>
>> > > >       </xsd:appinfo>
>> > > >     </xsd:annotation>
>> > > >     <xsd:sequence>
>> > > >       <xsd:element name="Name" type="xsd:string"
>> csx:propertyID="3456"/>
>> > > >       <xsd:element name="Salary" type="xsd:int"
>> csx:propertyID="3457"/>
>> > > >     </xsd:sequence>
>> > > >   </xsd:complexType>
>> > > > </xsd:element>
>> > > > </xsd:schema>
>> > > >
>> > > > And I got the XSElementDeclaration item from Xerces that represents
>> the
>> > > > Employee element in this case, the problem here is that I don't know
>> how
>> > > to
>> > > > extract the csx:propertyID attribute and the appinfo annotation.
>> Anyone
>> > > > knows what API can I use to get them?
>> > > >
>> > > > Thanks,
>> > > > Luis.
>> > > >
>> > > > --
>> > > >
>> > > > "The significant problems we face cannot be solved by the same level
>> of
>> > > > thinking that created them."  -- Albert Einstein
>> > >
>> >
>> > --
>> >
>> > "The significant problems we face cannot be solved by the same level of
>> > thinking that created them."  -- Albert Einstein
>>
>> Thanks.
>>
>> Michael Glavassevich
>> XML Technologies and WAS Development
>> IBM Toronto Lab
>> E-mail: mrgla...@ca.ibm.com
>> E-mail: mrgla...@apache.org
>>
>
>

Reply via email to