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