On Fri, 31 Aug 2001, Andreas [iso-8859-1] Th�nnessen wrote:
> Which parser provides the method getValidator()?
> I couldn't find it in the apidocs (Xerces-J 1.4.1/1.4.3/2.0.0.beta2)
> Do I have to set up the Grammar, XMLValidator etc. manually for a
> "customized" parser? That's what I hoped to avoid ;-)
I subclassed DOMParser:
public class MemeDOMParser
extends org.apache.xerces.parsers.DOMParser {
public StringPool getStringPool() {
return this.fStringPool;
}
public XMLValidator getValidator() {
return this.fValidator;
}
}
fValidator is protected.
> > InsertableElementsInfo info =
> > this.makeInfoObject (node);
>
> Do you construct thie InsertableElementsInfo completely new (e.g.
> based on the schema tree - should be easy), or is it possible to get
> (at least) the possibleChildren[] from where ever the
> parser/validator stored this info on parsing the DTD/schema?
I'm not sure I understand your question, but here's the relevant method.
(I probably should have just tarred the files up and sent them whole):
public InsertableElementsInfo makeInfoObject (Node n) {
InsertableElementsInfo info = new InsertableElementsInfo();
Node parent = n.getParentNode();
NodeList children = parent.getChildNodes();
int childCount = children.getLength();
info.curChildren = new QName[childCount];
info.childCount = childCount;
for (int i = 0; i < info.childCount; i++) {
Node child = children.item(i);
int index = this.getElementIndex(child.getNodeName());
info.curChildren[i] = new QName(-1, index, index);
if (child == n) {
info.insertAt = i;
info.curChildren[i] = null;
}
}
return (info);
}
> > Grammar g = val.getGrammar();
>
> Again I cannot see the method getGrammar() in the apidocs of
> XMLValidator!?
After poking around my code, I discovered that I actually added
getGrammar() to XMLValidator:
public Grammar getGrammar() {
return(this.fGrammar);
}
and made my clients use that modified version of Xerces. Ouch. Perhaps
this makes this approach unusable by you.
In general, I found that there were useful methods that I wanted to use in
Xerces, but that they were no longer supported. I could get things
working, but it took modifications (I don't think that was the only place
where I modified Xerces). I think that Xerces2 is going to support
validator access in a more direct fashion.
j
---
"Users complain that they receive too much spam, while spammers protest
messages are legal." -InfoWorld
"You do not have to do everything disagreeable that you have a right to
do." -Judith Martin (Miss Manners)
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]