Fields Summary |
---|
private final InsulatedValidatorComponent | validatorThe actual validator. |
private final XMLDocumentFilter | validatorFiltervalidator.getValidator() . |
private final XNI2SAXEx | xni2saxUsed to adopt the output from a validtor to the input of
the user specified {@link ContentHandler}. |
private final SymbolTable | symbolTable |
private final NamespaceSupport | nsContext |
private final ValidationManager | validationManager |
private final XMLEntityManager | entityManager |
private final XMLErrorReporter | errorReportererror reporter is used to format error messages. |
private ErrorHandler | errorHandlerUser-specified error handler. Maybe null. |
private boolean | inStartElementThis flag is set to true while we are processing the startElement event. |
private boolean | namespacePrefixesFeatureThe value of the http://xml.org/sax/features/namespace-prefixes feature. |
private final ErrorHandlerAdaptor | xercesErrorHandlerUsed by {@link XMLDTDValidator} to report errors. |
private LSResourceResolver | resourceResolverUser-specified entity resolver. Maybe null. |
private final XMLComponentManager | manager |
private Locator | locator |
private final TypeInfoProvider | typeInfoProvider{@link TypeInfoProvider} implementation.
REVISIT: I'm not sure if this code should belong here. |
private final XMLAttributes | xaonly one instance of XMLAttributes is used. |
Methods Summary |
---|
public void | characters(char[] buf, int offset, int len)
try {
validatorFilter.characters(new XMLString(buf,offset,len),null);
} catch( WrappedSAXException e ) {
throw e.exception;
}
|
private com.sun.org.apache.xerces.internal.xni.XMLAttributes | createAttributes(org.xml.sax.Attributes att)Creates an XMLAttributes object.
xa.removeAllAttributes();
int len = att.getLength();
for (int i = 0; i < len; i++) {
int idx = xa.addAttribute(
createQName(att.getURI(i), att.getLocalName(i), att.getQName(i)),
att.getType(i),
att.getValue(i));
// attributes present in the original SAX event streams
// are considered as "specified".
xa.setSpecified(idx,true);
}
return xa;
|
private com.sun.org.apache.xerces.internal.xni.QName | createQName(java.lang.String uri, java.lang.String local, java.lang.String raw)Creates a QName object.
if( local.length()==0 ) {
// if naemspace processing is turned off, local could be "".
// in that case, treat everything to be in the no namespace.
uri = "";
local = raw;
}
int idx = raw.indexOf(':");
String prefix;
if (idx < 0)
prefix = null;
else
prefix = raw.substring(0, idx);
if (uri != null && uri.length() == 0)
uri = null; // XNI uses null whereas SAX uses the empty string
return new QName(symbolize(prefix), symbolize(local), symbolize(raw), symbolize(uri));
|
private com.sun.org.apache.xerces.internal.xni.XMLString | createXMLString(java.lang.String str)
// with my patch
// return new XMLString(str);
// for now
return new XMLString(str.toCharArray(), 0, str.length());
|
public void | endDocument()
try {
validatorFilter.endDocument(null);
} catch( WrappedSAXException e ) {
throw e.exception;
}
|
public void | endElement(java.lang.String uri, java.lang.String local, java.lang.String qname)
try {
validatorFilter.endElement(createQName(uri,local,qname),null);
} catch( WrappedSAXException e ) {
throw e.exception;
}
|
public void | endPrefixMapping(java.lang.String prefix)
nsContext.popContext();
|
public final org.xml.sax.ContentHandler | getContentHandler()
return xni2sax.getContentHandler();
|
private final com.sun.org.apache.xerces.internal.xni.XMLAttributes | getCurrentAttributes()Obtains the current attributes.
return xni2sax.getCurrentAttributes();
|
private final com.sun.org.apache.xerces.internal.xni.Augmentations | getCurrentAugmentation()Obtains the current augmentation.
used for {@link javax.xml.validation.TypeInfoProvider}.
return xni2sax.getCurrentAugmentation();
|
public org.xml.sax.ErrorHandler | getErrorHandler()
return errorHandler;
|
public boolean | getFeature(java.lang.String name)
if( name.equals("http://xml.org/sax/features/namespace-prefixes") )
return namespacePrefixesFeature;
return super.getFeature(name);
|
public org.w3c.dom.ls.LSResourceResolver | getResourceResolver()
return resourceResolver;
|
public javax.xml.validation.TypeInfoProvider | getTypeInfoProvider()
return typeInfoProvider;
|
public void | ignorableWhitespace(char[] buf, int offset, int len)
try {
validatorFilter.ignorableWhitespace(new XMLString(buf,offset,len),null);
} catch( WrappedSAXException e ) {
throw e.exception;
}
|
public boolean | isValidSoFar()
return !xercesErrorHandler.hadError();
|
public void | processingInstruction(java.lang.String target, java.lang.String data)
try {
validatorFilter.processingInstruction(
symbolize(target),createXMLString(data),null);
} catch( WrappedSAXException e ) {
throw e.exception;
}
|
public void | reset()Resets this handler.
Meaning resets all the user-specified configurations to the
initial state, then also resets all the components.
resetComponents();
errorHandler = null;
resourceResolver = null;
|
private void | resetComponents()Resets the components we use internally.
// reset the error flag when we start a new validation.
xercesErrorHandler.reset();
nsContext.reset();
errorReporter.reset(manager);
validator.reset(manager);
|
public final void | setContentHandler(org.xml.sax.ContentHandler result)
xni2sax.setContentHandler(result);
if(result==null) validatorFilter.setDocumentHandler(null);
else validatorFilter.setDocumentHandler(xni2sax);
|
public void | setDocumentLocator(org.xml.sax.Locator _loc)
this.locator = _loc;
|
public void | setErrorHandler(org.xml.sax.ErrorHandler errorHandler)
this.errorHandler = errorHandler;
|
public void | setFeature(java.lang.String name, boolean value)
if( name.equals("http://xml.org/sax/features/namespace-prefixes") ) {
namespacePrefixesFeature = value;
return;
}
super.setFeature(name, value);
|
public void | setResourceResolver(org.w3c.dom.ls.LSResourceResolver entityResolver)
this.resourceResolver = entityResolver;
|
public void | skippedEntity(java.lang.String name)
// there seems to be no corresponding method on XMLDocumentFilter.
// just pass it down to the output, if any.
ContentHandler handler = getContentHandler();
if( handler!=null )
skippedEntity(name);
|
public void | startDocument()
//
//
// ContentHandler implementation
//
//
try {
resetComponents();
XMLLocator xmlLocator = (locator==null)?null:new LocatorWrapper(locator);
// set the locator to the error reporter
errorReporter.setDocumentLocator(xmlLocator);
validatorFilter.startDocument(
xmlLocator,
null,
nsContext,
null);
} catch( WrappedSAXException e ) {
throw e.exception;
}
|
public void | startElement(java.lang.String uri, java.lang.String local, java.lang.String qname, org.xml.sax.Attributes att)
try {
inStartElement = true;
validatorFilter.startElement(createQName(uri,local,qname),createAttributes(att),null);
} catch( WrappedSAXException e ) {
throw e.exception;
} finally {
inStartElement = false;
}
|
public void | startPrefixMapping(java.lang.String prefix, java.lang.String uri)
nsContext.pushContext();
nsContext.declarePrefix(prefix,uri);
|
private java.lang.String | symbolize(java.lang.String s)Symbolizes the specified string.
//
//
// helper methods
//
//
if (s == null)
return null;
else
return symbolTable.addSymbol(s);
|