Title:

Max (and anybody who can help me),

 

   I tried out that but it result in a java.lang.ClassCastException.. the code is this :

 

XMLParserConfiguration config = new StandardParserConfiguration();

            config.setProperty("http://apache.org/xml/properties/internal/grammar-pool",grammarPool);

            DOMParser parser = new DOMParser(config);

            parser.setFeature("http://xml.org/sax/features/validation",true);

            parser.setFeature("http://apache.org/xml/features/validation/schema",true);

            parser.parse(filename);

            doc = parser.getDocument();

            

            org.apache.xerces.impl.xs.psvi.XSModel model = grammarPool.toXSModel();

           

            XSElementDeclaration elem = ((XSModelImpl) model).getElementDeclaration("os",null);

 

            // this line ocurrs the exception.. the XSElementDeclaration cannot be casted into a ((ElementPSVI

            XSElementDeclaration elemson = ((ElementPSVI) elem).getElementDeclaration();

 

I �ve been looking into the xerces documentation but I still havent found a way to get the XSElementDeclaration that are child of a XSElementDeclaration.

 

Thanks,

 

Rubens Del Monte

 

 

 

-----Mensagem original-----
De: Maksym Kovalenko [mailto:[EMAIL PROTECTED]
Enviada em: ter�a-feira, 7 de outubro de 2003 16:53
Para: [EMAIL PROTECTED]
Assunto: Re: Can�t acess child elements definition

 

For child element you can extract its declaration as the following

XSElementDeclaration elDecl = ((ElementPSVI) childElement).getElementDeclaration();

The error in the code you've provided is that to get element declaration for child elements you need to process content of the root element.
model.getComponents(XSConstants.ELEMENT_DECLARATION); contains only information for elements defined in the schema's top level.

Max

Rubens Del Monte wrote:

Hello,

    I�m starting to develop an application with Xerces and I�m having some trouble acessing the validation information of  child nodes.

My code is the following :

XMLParserConfiguration config = new StandardParserConfiguration();

// the pool is empty, but the schema is loaded when parsed, and the validation occurs

            config.setProperty("http://apache.org/xml/properties/internal/grammar-pool",grammarPool);

            DOMParser parser = new DOMParser(config);

            parser.setFeature("http://xml.org/sax/features/validation",true);

            parser.setFeature("http://apache.org/xml/features/validation/schema",true);

            parser.parse(filename);

            doc = parser.getDocument();

           

            org.apache.xerces.impl.xs.psvi.XSModel model  = grammarPool.toXSModel();

            // the only element this brings is the root node

XSNamedMap element = model.getComponents(XSConstants.ELEMENT_DECLARATION);

// I first tried this, but it only works with the root element, none of the others. They don�t have namespace too…

XSElementDeclaration elem = ((XSModelImpl) model).getElementDeclaration("os",null);

….

If anyone can help me, please, I�ve been trying to do this but it�s taking too long…

Thanks,

Rubens Del Monte

 

--


Maksym Kovalenko
Software Engineer
Marketswitch Corporation
http://www.marketswitch.com
108 Powers Court, Suite 225
Dulles, VA 20166
Phone: +1 (703) 444-6750 ext. 302
Fax: +1 (703) 444-6812

Reply via email to