Dick Deneer <[EMAIL PROTECTED]> wrote on 12/30/2005 10:14:20 AM: > Maybe this is more a posting for the developer forum, becauses it > addresses some rather technical issues while working with the > DTDGrammar class. > > While working to improve the support for DTD editing in my xml editor, > I came across some issues with the DTDGrammar class. > > 1. It would be very nice to be able to get the ContentSpecIndex for an > element. I tried to workaround this with the following code in my own > program: > int chunk = elementDeclIndex >> CHUNK_SHIFT; > int index = elementDeclIndex & CHUNK_MASK; > int contentSpecIndex = > grammar.fElementDeclContentSpecIndex[chunk][index]; > > But to get this working I had to change the private identifier of > fElementDeclContentSpecIndex in DTDGrammar to public. > So a public function getElementContentSpecIndex (int elementDeclIndex) > would be very nice. > This way you can get the first "contentModel particle", and from there > work up to the containging particles (like the method > getContentSpecAsString in DTDGrammar does). > By the way I saw that this issue was already posted long time ago in > XERCESJ-618
Although we really don't encourage folks to use this stuff, I guess it would be okay to add such a method. Just a word of warning if you're going to be using DTDGrammar or any other classes/interfaces under org.apache.xerces.impl --- they are public in the Java sense however they are internal to Xerces. Usage of these classes is unsupported and they are subject to change without notice. That said DTDGrammar has been fairly stable so it's unlikely your code would break in the future. > 2. In DTDGrammar there is a function getElementDeclIndex(elementName) > to get the index of the ElementDeclaration. > But it looks like this does not always work. Maybe the String object of > the elementName must be exact the same object as stored in the > DTDGramar class ???. I had to program a workaround by just looping > through all the elementDeclarions (by means of method > grammar.getNextElementDeclIndex(i)) This method and many others do reference comparison instead of calling String.equals(). It works because the parser always passes in internalized strings [String.intern()] from its SymbolTable for element names, attribute names, etc... If you're calling this method you have to do the same. > Regards > Dick Deneer > Thanks. Michael Glavassevich XML Parser Development IBM Toronto Lab E-mail: [EMAIL PROTECTED] E-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
