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 Stanimir Stamenkov <st...@myrealbox.com> on 2004/11/05 12:12:36 UTC

DTDGrammar - ContentSpec

Hello,

I'm trying to analyze a DTD document using the 'DTDGrammar' 
interface. I load the DTD using 'XMLDTDLoader' instance. Then I use 
'getFirstElementDeclIndex()', 'getNextElementDeclIndex(int)', 
'getElementDecl(int, XMLElementDecl)' to traverse through the 
declarations. Now I try to  analyze the content model of each 
declaration but seem I can't get how the 'getContentSpec(int, 
XMLContentSpec)' behaves. The index I'm passing as argument is that 
I've used to obtain the corresponding element declaration. The 
results I get:

<!ELEMENT a (b, c)>

<!ELEMENT e (#PCDATA)>

<!ELEMENT f (#PCDATA)>

<!ELEMENT b ANY>

<!ELEMENT c (e, f)>

Seems like:

XMLElementDecl decl = new XMLElementDecl();
XMLContentSpec spec = new XMLContentSpec();

getElementDecl(1, decl);  // returns "e" element declaration;
getContentSpec(1, spec);  // returns something different from
                           // what I expect;

The content spec returned from the second method call seems to 
return an 'XMLContentSpec' representing the second particle in the 
"a" element content spec, i.e. "c".

Could somebody give me some hint here?

-- 
Thank you in advance,
Stanimir


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


Re: DTDGrammar - ContentSpec

Posted by Stanimir Stamenkov <st...@myrealbox.com>.
/Suresh Babu Koya/:

> You can register a Call back handler for DTD declarations and 
> you have to build your own object model. Use Andy Clark's code of 
> Neko. This will handle parametric entities also.

The idea is not to build object model of my own, but to use what has 
already been implemented. I've wondered why the 'XMLElementDecl' has 
'simpleType' property which for XML DTDs would be always 'null' and 
doesn't provide index (some sort of reference) to the content model.

Looking at the 'DTDGrammar.getContentSpecAsString(int)' method I was 
temped to make an utility function to give me the desired index but 
the necessary fields have private access only.

Whatever. Most probably, I'll have to build the model myself. Thank 
you, for your comments.

-- 
Stanimir


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


RE: DTDGrammar - ContentSpec

Posted by Suresh Babu Koya <sk...@in-reality.com>.
You can register a Call back handler for DTD declarations and  
you have to build your own object model. Use Andy Clark's code of
Neko. This will handle parametric entities also.  

Regards,
Suresh Koya     

>>-----Original Message-----
>>From: Stanimir Stamenkov [mailto:stanio@myrealbox.com]
>>Sent: Monday, November 08, 2004 4:43 PM
>>To: xerces-j-user@xml.apache.org
>>Subject: Re: DTDGrammar - ContentSpec
>>
>>
>>/Stanimir Stamenkov/:
>>
>>> Now I try to  analyze the content model of each 
>>> declaration but seem I can't get how the 'getContentSpec(int, 
>>> XMLContentSpec)' behaves. The index I'm passing as argument is 
>>that I've 
>>> used to obtain the corresponding element declaration.
>>
>>O.k. I realize I need a different index and I've made the following 
>>experiment:
>>
>>http://www.geocities.com/stanio/test/DTDModelTest.java.txt
>>http://www.geocities.com/stanio/test/content.dtd.txt
>>
>>(remove the .txt name extension after the download)
>>
>>Extending the 'XMLDTDLoader' to intercept the standard handling and 
>>access the 'DTDGrammar' being built I'm able to build a map for the 
>>element names and the corresponding content spec indexes. It is 
>>pretty dirty hack and it is not guaranteed to work if the 
>>implementation changes. So I've wondered how the built content spec 
>>table is used currently?
>>
>>I've also read 
>><http://xml.apache.org/xerces2-j/faq-grammars.html#faq-5>:
>>
>>> No such API exists at the current moment for DTD's.
>>
>>and "DTDGrammar - getContentSpec" 
>><http://nagoya.apache.org/bugzilla/show_bug.cgi?id=10989>, but I 
>>still wonder.
>>
>>-- 
>>Stanimir
>>
>>
>>---------------------------------------------------------------------
>>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


Re: DTDGrammar - ContentSpec

Posted by Stanimir Stamenkov <st...@myrealbox.com>.
/Stanimir Stamenkov/:

> Now I try to  analyze the content model of each 
> declaration but seem I can't get how the 'getContentSpec(int, 
> XMLContentSpec)' behaves. The index I'm passing as argument is that I've 
> used to obtain the corresponding element declaration.

O.k. I realize I need a different index and I've made the following 
experiment:

http://www.geocities.com/stanio/test/DTDModelTest.java.txt
http://www.geocities.com/stanio/test/content.dtd.txt

(remove the .txt name extension after the download)

Extending the 'XMLDTDLoader' to intercept the standard handling and 
access the 'DTDGrammar' being built I'm able to build a map for the 
element names and the corresponding content spec indexes. It is 
pretty dirty hack and it is not guaranteed to work if the 
implementation changes. So I've wondered how the built content spec 
table is used currently?

I've also read 
<http://xml.apache.org/xerces2-j/faq-grammars.html#faq-5>:

> No such API exists at the current moment for DTD's.

and "DTDGrammar - getContentSpec" 
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=10989>, but I 
still wonder.

-- 
Stanimir


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