Seems to me that, for the example you gave, what you need to get is properties of schema components, at the component level, rather than the XML representation level. This can be done by using XSModel.
There are 2 ways of doing so: Xerces grammar preparsing, or PSVI. 1. Preparsing: You can use the Xerces XMLGrammarPreparser to parse your schema to an XSGrammar Object (please refer to the xni.GrammarBuilder sample). Then you can put it in a grammar pool, and set the pool onto the parser. To examine various properties of the components, you can convert the schema grammar to an XSModel (using the toXSModel method), and use methods defined on XSModel and other related interfaces. 2. PSVI One of the FAQs [1] describes how to use PSVI in DOM. If you build a PSVI DOM, you can check which elements/attributes are valid, and the element/attribute declarations and type definitions used to validate these nodes. In your example, you can find the invalid node, get its type definition, and examine the enumeration values. [1] http://xml.apache.org/xerces2-j/faq-xs.html#faq-5 Cheers, Sandy Gao Software Developer, IBM Canada (1-905) 413-3255 [EMAIL PROTECTED] Nicolas.GOLOUBENK [EMAIL PROTECTED] To: [EMAIL PROTECTED] cc: 04/28/2003 12:29 Subject: Réf. : Re: Réf. : Re: Réf. : RE: XSModel PM Please respond to xerces-j-user >You mean put it in a grammar pool, and give the pool to the parser? I mean loading a schema and making the parser to use it for validation. But I didn't upgrade my code since weeks, and I continue to use this kind of code : ASModel asModel = parser.parseASInputSource(in); // 'in' is an DOMInputSource which points to a schema parser.setAbstractSchema(asModel); // 'parser' is an instance of DOMASBuilder >If you want to check the properties of various schema components, then >XSModel is the answer. >If you want to check the original XML representation of the schema, then >no, not in the Xerces world. The Xerces schema doesn't retain such >information. Ex. : Model : <xsd:complexType name="insSERIAL_LINK_T"> <xsd:simpleContent> <xsd:restriction base="EnumDef_T"> <xsd:enumeration value="port A"/> <xsd:enumeration value="port B"/> <xsd:attribute ref="label" fixed="Serial link"/> <xsd:attribute ref="editable" fixed="1"/> </xsd:restriction> </xsd:simpleContent> </xsd:complexType> <xsd:element name="insSERIAL_LINK" type="insSERIAL_LINK_T" default="port A"/> Instance to validate against model : <insSERIAL_LINK>port X</insSERIAL_LINK> When a validation error occurs, I want to use the 'label' attribute to build a user error message which would look like : ERROR : Serial link is not correct ; should be either 'port A' or 'port B' So I need to get the label attribute content to build the message (and, in this example, the different values). What I really need is to retrieve the complete DOM node (because I use a DOM parser) in error, populated with complementary information (such as the label attribute) by the parser. This could allow me to get all the properties of my data to alert the user of how to use it. Till now, I parse my schema as a simple xml instance thanks to another parser to retrieve these properties. So my question was : can I use the XSModel to introspect schemas and retrieve data properties because the native validation error message does not return all the information of the element. Thank you very much Cheers, Sandy Gao Software Developer, IBM Canada (1-905) 413-3255 [EMAIL PROTECTED] Nicolas.GOLOUBENK [EMAIL PROTECTED] To: [EMAIL PROTECTED] cc: 04/28/2003 11:24 Subject: Réf. : Re: Réf. : RE: XSModel AM Please respond to xerces-j-user Absolutely, you're right ! I'm sorry, I made a confusion between ASModel and XSModel. I profit from this discussion to ask my question a second time : after setting a schema model to a dom parser to validate XML instances against this schema, does any API exist to introspect the schema itself without parsing it a second time with another parser ? Thank you "Sandy Gao" <[EMAIL PROTECTED] Pour : [EMAIL PROTECTED] ibm.com> cc : Objet : Re: Réf. : RE: XSModel 04/28/2003 05:11 PM Veuillez répondre à xerces-j-user > Someone answers me that XSModel was dead and should not be used now. Huh?! XSModel *is* alive, and will be alive for some time (hopefully a long time). But as Robert said, it might be moved to a different package. Is it possible that you are confusing it with ASModel? Thanks, Sandy Gao Software Developer, IBM Canada (1-905) 413-3255 [EMAIL PROTECTED] Nicolas.GOLOUBENK [EMAIL PROTECTED] To: [EMAIL PROTECTED] cc: 04/28/2003 11:06 Subject: Réf. : RE: XSModel AM Please respond to xerces-j-user I asked a question like that a few weeks ago. Someone answers me that XSModel was dead and should not be used now. Because I had to introspect schemas, I decided to use a simple XML parser to do that instead of using a specific XSD API. Nicolas "Robert Houben" Pour : <[EMAIL PROTECTED]> <[EMAIL PROTECTED] cc : s.net> Objet : RE: XSModel 04/28/2003 04:51 PM Veuillez répondre à xerces-j-user They are deprecated because they "might move" to another package. You are not the first person to be confused by this. (I wasn't the first, either!) Go ahead and use them. Robert Houben mailto:[EMAIL PROTECTED] http://www.RobertHouben.com/ -----Original Message----- From: Blake Meike [mailto:[EMAIL PROTECTED] Sent: Monday, April 28, 2003 7:44 AM To: [EMAIL PROTECTED] Subject: XSModel Hey, this is confusing. All the documentation I can find about manipulating an XS Grammar says to get the grammar from the grammar pool, after the XSD is parsed, cast it to an XSGrammar, and then use the "toXSModel()" method to obtain an object for inspection. When I try to actually do this, it turns out that XSModel and everything about it are deprecated. So what is replacing them? Blake Meike --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]