Hello Alberto,

Alberto Massari wrote:
>
> 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.
>
DOMBuilderImpl inherits protected getGrammarResolver() from baseclass
AbstractDOMParser. So I see no way to acces it. Neither by downcast.

>> How do I get XMLElementDecl from SchemaGrammar?
>
> 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());
>
Yes, this should work. But I don't know the structure of my XML. So using
this approach means traversing through getParentNode(), right?

My hope is PSV can help. Isn't it?

DOMPSVITypeInfo *typeInfo =
(DOMPSVITypeInfo*)domNode->getInterface(XMLUni::fgXercescInterfacePSVITypeInfo);
const XMLCh *typeName =
typeInfo->getStringProperty(DOMPSVITypeInfo::PSVI_Type_Definition_Name);
const XMLCh *typeURI =
typeInfo->getStringProperty(DOMPSVITypeInfo::PSVI_Type_Definition_Namespace);


Thanks,
Michael

> 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