Hi Michael,

At 18.28 18/12/2005 +0100, Michael Hagedorn wrote:
Alberto,

Thanks a lot for your help!
I have to use DOMBuliderImpl. Method getGrammarResolver is inaccessible for
this one.

You could use parser->getGrammar("urn:my:namespace"), but you really need the GrammarResolver in order to get the uriId for a given namespace. You have to downcast the pointer to DOMBuilderImpl.

How do I get XMLElementDecl from SchemaGrammar?
By the way, NodeName of my element ("title") is not necessarily unique in my
XSD.

The code I wrote assumes that "title" is a global element; if it is a local element you may want to drill down from the corresponding global element. So, if you look for the "title" of a "book" inside the global "books" you will have to search

SchemaElementDecl* books=(SchemaElementDecl*)g->getElemDecl(r->getStringPool()->getId("urn:my:namespace"),
"books", 0, Grammar::TOP_LEVEL_SCOPE);

SchemaElementDecl* book=(SchemaElementDecl*)g->getElemDecl(r->getStringPool()->getId("urn:my:namespace"),
"book", 0, books->getComplexTypeInfo()->getScopeDefined());

SchemaElementDecl* title=(SchemaElementDecl*)g->getElemDecl(r->getStringPool()->getId("urn:my:namespace"),
"title", 0, book->getComplexTypeInfo()->getScopeDefined());

Alberto


Regards,
Michael

> --- Ursprüngliche Nachricht ---
> Von: Alberto Massari <[EMAIL PROTECTED]>
> An: [email protected]
> Betreff: Re: xs:appinfo
> Datum: Fri, 16 Dec 2005 13:15:50 +0100
>
> Hi Micael,
> you can query the parser for the grammar used during validation, like
> in this pseudo-code
>
> parser.setGenerateSyntheticAnnotations(true);
> //or, if using SAX2 or DomBuilder
> parser.setFeature(XMLUni::fgXercesGenerateSyntheticAnnotations,true);
>
> // parse your file with validation on
>
> GrammarResolver* r=parser.getGrammarResolver();
> SchemaGrammar* g=(SchemaGrammar*)r->getGrammar("urn:my:namespace");
> XMLElementDecl*
> elem=g->getElemDecl(r->getStringPool()->getId("urn:my:namespace"),
> "titel", 0, Grammar::TOP_LEVEL_SCOPE);
> XSAnnotation* a=g->getAnnotation(elem);
> XMLCh* text=a->getAnnotationString();
>
> Hope this helps,
> Alberto
>
> At 21.02 14/12/2005 +0100, Michael Hagedorn wrote:
> >Hi All,
> >
> >After parsing a document I need to acces xs:appinfo information
> >associated with an element and I'v have no idea how to do it - execpt to
> >parse XSD file too.
> >
> >sample snippet (xsd):
> >             <xs:element name="titel" type="xtest:type.Titel">
> >                 <xs:annotation>
> >                     <xs:appinfo>KEY=7E</xs:appinfo>
> >                 </xs:annotation>
> >             </xs:element>
> >
> >Thanks for your help,
> >Michael
>
>


Reply via email to