You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xerces.apache.org by Nikhil Dinesh <ni...@seas.upenn.edu> on 2004/09/01 20:26:29 UTC

Re: element set validation

Ive tried this only while validating against a DTD, but "I think" you
should be able to do it for a schema as follows:

1. Use org.apache.impl.xs.XMLSchemaLoader to load the schema. This should
give you an instance of org.apache.xerces.xs.XSModel

2. Use xsModel.getTypeDefinition(...) to get the type definition. This
will be an org.apache.xerce.xs.XSSimpleTypeDefinition in your case.

3. Heres where Im not sure, but you should be able to cast this up to
org.apache.xerces.impl.dv.XSSimpleType. The you can use one of the
validate methods on this to validate your simpleType.

If you want to validate IDs and IDREFS as well you will need to update an
instance of org.apache.xerces.impl.dv.ValidationContext. Keys and their
references would also require some such mechanism. So there is not too
much you can achieve here without running into the complexities required
for full validation.

But if all your elements are indeed simpleTypes then there should be no
structure and using these methods would have comparable efficiency to full
validation if you are checking simpleTypeDefinitions on every element. It is
only if you have a lot of markup that this will help.

-Nikhil

On Tue, 31 Aug 2004 ighbal@tiscali.it wrote:

> ok, let's try to be more preciseabout my schema structure...
>
> All the element defined in my schema are defined with a user-defined simpleType
> with a list of restrictions....
>
> so,when i talk about validations of a subset of nodes...i mean the facets
> checking stuff...i do not care about structure validation.
>
> is it not possible to identify the simpleType definition associated to an
> element, and then check all the facets?
>
> thanks in advance
>
> Serge Scevenels
> >-- Messaggio Originale --
> >Reply-To: xerces-j-user@xml.apache.org
> >Subject: Re: element set validation
> >From: Phil Weighill-Smith <ph...@volantis.com>
> >To: xerces-j-user@xml.apache.org
> >Date: Tue, 31 Aug 2004 11:39:41 +0100
> >
> >
> >You may or may not be able to validate a document fragment against a
> >given schema depending on how the schema is written.
> >
> >If your schema is written to restrict the location of any given element
> >to the context of its allowed parent you probably can't just validate
> >the "child" element (even creating a dummy parent may not be enough,
> >depending on the schema rules for the content of that parent and so on
> >up to your schema's root element).
> >
> >If, however, your schema doesn't restrict a given element to a specific
> >context you can easily validate that element by simply applying
> >validation to that element (how you do this depends on which DOM level
> >you're using; below DOM level 3 you need to essentially serialize your
> >DOM sub-tree such that you can parse it again with a (SAX) parser,
> >looking for errors. At DOM level 3 you *should* be able to utilize
> >DOM-based re-validation... (having said that, I'm no XERCES expert and
> >don't know if it supports DOM-based re-validation).
> >
> >Don't know if that helps...
> >
> >Phil :n.
> >On Tue, 2004-08-31 at 10:38, ighbal@tiscali.it wrote:
> >
> >> hi
> >>
> >> i am currently trying to find a solution to the following problem:
> >>
> >> I would like to be able to validate some node of my xml file instead
> of
> >> validate all the document.
> >> Moreover, is this is possible with a unique xml schema, i.e., the one
> that
> >> apply to the whole document.
> >>
> >> Why i want to do that?
> >>
> >> just because my xml file is huge, and from this file, according to my
> needs,
> >> i have to extract only a subset of this file. And this subset is not
> always
> >> the same.
> >>
> >> thanks in advance
> >>
> >> Serge Scevenels
> >>
> >> __________________________________________________________________
> >> Tiscali ADSL Senza Canone, paga solo quello che consumi!
> >> Non perdere la promozione valida fino al 31 agosto. Per te gratis il
> modem
> >> in comodato e l'attivazione. In piu' navighi a soli 1,5 euro l'ora per
> >i
> >> primi tre mesi. Cosa aspetti? Attivala subito!
> >> http://abbonati.tiscali.it/adsl/prodotti/640Kbps/
> >>
> >>
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
> >> For additional commands, e-mail: xerces-j-user-help@xml.apache.org
> >
> >--
> >Phil Weighill-Smith <ph...@volantis.com>
> >Volantis Systems
>
>
> __________________________________________________________________
> Tiscali ADSL Senza Canone, paga solo quello che consumi!
> Non perdere la promozione valida fino al 31 agosto. Per te gratis il modem
> in comodato e l'attivazione. In piu' navighi a soli 1,5 euro l'ora per i
> primi tre mesi. Cosa aspetti? Attivala subito!
> http://abbonati.tiscali.it/adsl/prodotti/640Kbps/
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-j-user-help@xml.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org