There's no "magic" method for getting the particle. A similar question [1] 
was asked a couple months ago. Here's what I said in response then:

"Xerces transforms the content model into a DFA (see [2]) which it uses 
for validation. We don't store the XSParticles in this representation but 
it should give you some idea of the complexity and perhaps a starting 
point."

It's probably worth looking at the content model builder [3] too.

[1] http://marc.theaimsgroup.com/?l=xerces-j-dev&m=116434532918157&w=2
[2] 
http://svn.apache.org/viewvc/xerces/java/trunk/src/org/apache/xerces/impl/xs/models/XSDFACM.java
[3] 
http://svn.apache.org/viewvc/xerces/java/trunk/src/org/apache/xerces/impl/xs/models/CMBuilder.java

Michael Glavassevich
XML Parser Development
IBM Toronto Lab
E-mail: [EMAIL PROTECTED]
E-mail: [EMAIL PROTECTED]

Ivan Todoroski <[EMAIL PROTECTED]> wrote on 01/24/2007 07:25:14 AM:

> On 24.01.2007 07:20, Michael Glavassevich wrote:
> > This is not a bug. The annotation is on a particle [1][2] not an 
element 
> > declaration so you're looking for it in the wrong place. You need to 
dig 
> > into the enclosing complex type definition to find it.
> 
> Thanks for the quick reply. I actually saw the XSParticle class and 
> went looking 
> in that direction, but was unable to figure out how to *reliably* 
> get to it from 
> inside the startElement() event for <child>.
> 
> The problem is, the program needs to work with a variety of XSDs 
notknown in 
> advance, therefore no schema-specific knowledge must be encoded in 
> it. So, the 
> program cannot "know" that it can get to the XSParticle for the <child> 
> reference by traversing the XSComplexTypeDefinition for <top>, and 
> following all 
> and sundry pointers through XSParticle.getTerm(), casting as appropriate 
and 
> then recursively through sub-XSParticles, until it finds the one for 
<child>.
> 
> During experimentation I was able to do this with a hand crafted 
> traversal code 
> that would work from the startElement() event for <top> and only for 
this 
> particular XSD, but as mentioned above this is not an option.
> 
> What I basically need, in addition to PSVIProvider.
> getElementDeclaration(), is a 
> magic method getTheParticleThatTriggeredValidation(), that I can usefrom 
the 
> startElement() event for <child>, and that would lead me to the 
> XSParticle for 
> the element reference.
> 
> Is there a way to accomplish something like this? A rough code snippet 
> demonstrating how to get to the XSParticle for the element referencefrom 
the 
> startElement() event for <child>, in a way that is not specific to 
> this sample 
> schema, would be much appreciated.
> 
> ---------------------------------------------------------------------
> 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]

Reply via email to