Hi Michael,
   Thanks for your reply.

   In XMLSchemaValidator, in handleEndElement method I am writing code
like following, for assertions processing:

ElementPSVImpl assertPSVI = new ElementPSVImpl();
assertPSVI.fDeclaration = fCurrentElemDecl;
assertPSVI.fTypeDecl = fCurrentType;
assertPSVI.fNotation = fNotation;

// set grammar ??

// construct the augmentations object for assertions.
// store assertPSVI into the augmentations
AugmentationsImpl assertAugs = new AugmentationsImpl();
assertAugs.putItem(Constants.ELEMENT_PSVI, assertPSVI);
assertionProcessor.endElement(element, assertAugs);

Then in XMLAssertPsychopathImpl (which is assertionProcessor) I do:

public void endElement(QName element, Augmentations augs) .. {
  ...

  ElementPSVI elemPSVI = (ElementPSVI)augs.getItem(Constants.ELEMENT_PSVI);
  ((PSVIElementNSImpl)currentAssertDomNode).setPSVI(elemPSVI);

  // now I need XSModel at this point

  If I do:
  XSModel fSchema =
((PSVIElementNSImpl)currentAssertDomNode).getSchemaInformation();

I can get fSchema as null, because currentAssertDomNode may not be the
root node of the XML document.

I need the XSModel for the "content model" of any element in the
original XML tree, which would be having assertion definitions. So my
grammar root may change depending where assertions are there.

It seems, as per your suggestion at,
http://markmail.org/message/zq3hrqiygu24euwi I can something like:

assertPSVI.fGrammars = fGrammarBucket.getGrammars();

at the location, // set grammar ?? above.

This *does* set the grammar. But I can see, that this is the global
grammar object (represeting the whole XML document). I cannot use it
for assertions processing, because I need the XSModel for some local
element (which could be some descendant in the XML tree).

For this, I was trying to construct a grammar from scratch as
following (as I wrote in my original mail in this thread):
// XX
SchemaGrammar schemaGrammar = new SchemaGrammar(null, null, null,
Constants.SCHEMA_VERSION_1_1);
...
...

But you are advising against this approach.

What do you suggest further to achieve, what I have described?

I have one other question please:

When I create SchemaGrammar from scratch for an element (as stated at
// XX above), I only set three things as follows:

schemaGrammar.addGlobalElementDecl (..
schemaGrammar.addGlobalTypeDecl (.. // only if the type is not anonymous
schemaGrammar.addGlobalNotationDecl (..

Do you think, these three calls are enough to complete create the
grammar for an element? Or do we need to set some other things as
well, on schemaGrammar?

On Sun, May 31, 2009 at 1:11 AM, Michael Glavassevich
<[email protected]> wrote:
> Hi Mukul,
>
> Mukul Gandhi <[email protected]> wrote on 05/30/2009 07:20:37 AM:
>
>> On Sat, May 30, 2009 at 4:36 PM, Mukul Gandhi <[email protected]>
>> wrote:
>> > 1. I cannot do,
>> > schemaGrammar.addGlobalTypeDecl(elementPSVI.getTypeDefinition());
>> > if the type is an anonymous type.
>> >
>> > It seem, *I need to do this* to have a fully populated schema.
>>
>> It seems I have found the workaround (as below):
>>
>> I can do,
>>
>> XSTypeDefinition typeDef = elementPSVI.getTypeDefinition();
>> if (!typeDef.getAnonymous()) {
>>    schemaGrammar.addGlobalTypeDecl(elementPSVI.getTypeDefinition());
>> }
>>
>> So, I do .addGlobalTypeDecl only if the type is not anonymous.
>
> Right. By definition anonymous types are never global.
>
>> So in this case, an XSElementDecl has all the necessary information.
>> Therefore, the following call is sufficient for this example:
>>
>> schemaGrammar.addGlobalElementDecl((XSElementDecl)elementPSVI.
>> getElementDeclaration());
>>
>> It seems, my problem is solved. But any comments on the approach I am
>> following would be great..
>
> Well, I didn't think you need to create a new SchemaGrammar. See my note [1]
> on this from earlier in the month.
>
>> --
>> Regards,
>> Mukul Gandhi
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [email protected]
>> For additional commands, e-mail: [email protected]
>
> Thanks.
>
> [1] http://markmail.org/message/zq3hrqiygu24euwi
>
> Michael Glavassevich
> XML Parser Development
> IBM Toronto Lab
> E-mail: [email protected]
> E-mail: [email protected]
>



-- 
Regards,
Mukul Gandhi

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to