Fields Summary |
---|
private static final String | NAMESPACE_PREFIXESFeature identifier: namespace prefixes. |
protected static final String | STRING_INTERNINGFeature identifier: string interning. |
private static final String | ERROR_REPORTERProperty identifier: error reporter. |
private static final String | NAMESPACE_CONTEXTProperty identifier: namespace context. |
private static final String | SCHEMA_VALIDATORProperty identifier: XML Schema validator. |
private static final String | SECURITY_MANAGERProperty identifier: security manager. |
private static final String | SYMBOL_TABLEProperty identifier: symbol table. |
private static final String | VALIDATION_MANAGERProperty identifier: validation manager. |
private XMLErrorReporter | fErrorReporterError reporter. |
private NamespaceContext | fNamespaceContextThe namespace context of this document: stores namespaces in scope |
private XMLSchemaValidator | fSchemaValidatorSchema validator. |
private SymbolTable | fSymbolTableSymbol table |
private ValidationManager | fValidationManagerValidation manager. |
private XMLSchemaValidatorComponentManager | fComponentManagerComponent manager. |
private final SAXLocatorWrapper | fSAXLocatorWrapperXML Locator wrapper for SAX. |
private boolean | fNeedPushNSContextFlag used to track whether the namespace context needs to be pushed. |
private HashMap | fUnparsedEntitiesMap for tracking unparsed entities. |
private boolean | fStringsInternalizedFlag used to track whether XML names and Namespace URIs have been internalized. |
private final QName | fElementQNameFields for start element, end element and characters. |
private final QName | fAttributeQName |
private final XMLAttributesImpl | fAttributes |
private final AttributesProxy | fAttrAdapter |
private final XMLString | fTempString |
private ContentHandler | fContentHandler |
private final XMLSchemaTypeInfoProvider | fTypeInfoProvider{@link TypeInfoProvider} implementation.
REVISIT: I'm not sure if this code should belong here. |
private final ResolutionForwarder | fResolutionForwarderSAX adapter for an LSResourceResolver. |
Methods Summary |
---|
public void | characters(com.sun.org.apache.xerces.internal.xni.XMLString text, com.sun.org.apache.xerces.internal.xni.Augmentations augs)
if (fContentHandler != null) {
// if the type is union it is possible that we receive
// a character call with empty data
if (text.length == 0) {
return;
}
try {
fContentHandler.characters(text.ch, text.offset, text.length);
}
catch (SAXException e) {
throw new XNIException(e);
}
}
|
public void | characters(char[] ch, int start, int length)
try {
fTempString.setValues(ch, start, length);
fSchemaValidator.characters(fTempString, null);
}
catch (XMLParseException e) {
throw Util.toSAXParseException(e);
}
catch (XNIException e) {
throw Util.toSAXException(e);
}
|
public void | comment(com.sun.org.apache.xerces.internal.xni.XMLString text, com.sun.org.apache.xerces.internal.xni.Augmentations augs)
|
public void | doctypeDecl(java.lang.String rootElement, java.lang.String publicId, java.lang.String systemId, com.sun.org.apache.xerces.internal.xni.Augmentations augs)
|
public void | emptyElement(com.sun.org.apache.xerces.internal.xni.QName element, com.sun.org.apache.xerces.internal.xni.XMLAttributes attributes, com.sun.org.apache.xerces.internal.xni.Augmentations augs)
/** Split empty element event. **/
startElement(element, attributes, augs);
endElement(element, augs);
|
public void | endCDATA(com.sun.org.apache.xerces.internal.xni.Augmentations augs)
|
public void | endDocument(com.sun.org.apache.xerces.internal.xni.Augmentations augs)
if (fContentHandler != null) {
try {
fContentHandler.endDocument();
}
catch (SAXException e) {
throw new XNIException(e);
}
}
|
public void | endDocument()
fSAXLocatorWrapper.setLocator(null);
try {
fSchemaValidator.endDocument(null);
}
catch (XMLParseException e) {
throw Util.toSAXParseException(e);
}
catch (XNIException e) {
throw Util.toSAXException(e);
}
|
public void | endElement(com.sun.org.apache.xerces.internal.xni.QName element, com.sun.org.apache.xerces.internal.xni.Augmentations augs)
if (fContentHandler != null) {
try {
fTypeInfoProvider.beginEndElement(augs);
fContentHandler.endElement((element.uri != null) ? element.uri : XMLSymbols.EMPTY_STRING,
element.localpart, element.rawname);
}
catch (SAXException e) {
throw new XNIException(e);
}
finally {
fTypeInfoProvider.finishEndElement();
}
}
|
public void | endElement(java.lang.String uri, java.lang.String localName, java.lang.String qName)
fillQName(fElementQName, uri, localName, qName);
try {
fSchemaValidator.endElement(fElementQName, null);
}
catch (XMLParseException e) {
throw Util.toSAXParseException(e);
}
catch (XNIException e) {
throw Util.toSAXException(e);
}
finally {
fNamespaceContext.popContext();
}
|
public void | endGeneralEntity(java.lang.String name, com.sun.org.apache.xerces.internal.xni.Augmentations augs)
|
public void | endPrefixMapping(java.lang.String prefix)
if (fContentHandler != null) {
fContentHandler.endPrefixMapping(prefix);
}
|
private void | fillQName(com.sun.org.apache.xerces.internal.xni.QName toFill, java.lang.String uri, java.lang.String localpart, java.lang.String raw)Fills in a QName object.
if (!fStringsInternalized) {
uri = (uri != null && uri.length() > 0) ? fSymbolTable.addSymbol(uri) : null;
localpart = (localpart != null) ? fSymbolTable.addSymbol(localpart) : XMLSymbols.EMPTY_STRING;
raw = (raw != null) ? fSymbolTable.addSymbol(raw) : XMLSymbols.EMPTY_STRING;
}
else {
if (uri != null && uri.length() == 0) {
uri = null;
}
if (localpart == null) {
localpart = XMLSymbols.EMPTY_STRING;
}
if (raw == null) {
raw = XMLSymbols.EMPTY_STRING;
}
}
String prefix = XMLSymbols.EMPTY_STRING;
int prefixIdx = raw.indexOf(':");
if (prefixIdx != -1) {
prefix = fSymbolTable.addSymbol(raw.substring(0, prefixIdx));
}
toFill.setValues(prefix, localpart, raw, uri);
|
private void | fillXMLAttribute(org.xml.sax.Attributes att, int index)Adds an attribute to the XMLAttributes object.
fillQName(fAttributeQName, att.getURI(index), att.getLocalName(index), att.getQName(index));
String type = att.getType(index);
fAttributes.addAttributeNS(fAttributeQName, (type != null) ? type : XMLSymbols.fCDATASymbol, att.getValue(index));
|
private void | fillXMLAttributes(org.xml.sax.Attributes att)Fills in the XMLAttributes object.
fAttributes.removeAllAttributes();
final int len = att.getLength();
for (int i = 0; i < len; ++i) {
fillXMLAttribute(att, i);
fAttributes.setSpecified(i, true);
}
|
private void | fillXMLAttributes2(org.xml.sax.ext.Attributes2 att)Fills in the XMLAttributes object.
fAttributes.removeAllAttributes();
final int len = att.getLength();
for (int i = 0; i < len; ++i) {
fillXMLAttribute(att, i);
fAttributes.setSpecified(i, att.isSpecified(i));
if (att.isDeclared(i)) {
fAttributes.getAugmentations(i).putItem(Constants.ATTRIBUTE_DECLARED, Boolean.TRUE);
}
}
|
public com.sun.org.apache.xerces.internal.xs.AttributePSVI | getAttributePSVI(int index)
return fTypeInfoProvider.getAttributePSVI(index);
|
public com.sun.org.apache.xerces.internal.xs.AttributePSVI | getAttributePSVIByName(java.lang.String uri, java.lang.String localname)
return fTypeInfoProvider.getAttributePSVIByName(uri, localname);
|
public org.xml.sax.ContentHandler | getContentHandler()
return fContentHandler;
|
public com.sun.org.apache.xerces.internal.xni.parser.XMLDocumentSource | getDocumentSource()
return fSchemaValidator;
|
public com.sun.org.apache.xerces.internal.xs.ElementPSVI | getElementPSVI()
return fTypeInfoProvider.getElementPSVI();
|
public org.xml.sax.ErrorHandler | getErrorHandler()
return fComponentManager.getErrorHandler();
|
public boolean | getFeature(java.lang.String name)
if (name == null) {
throw new NullPointerException();
}
try {
return fComponentManager.getFeature(name);
}
catch (XMLConfigurationException e) {
final String identifier = e.getIdentifier();
final String key = e.getType() == XMLConfigurationException.NOT_RECOGNIZED ?
"feature-not-recognized" : "feature-not-supported";
throw new SAXNotRecognizedException(
SAXMessageFormatter.formatMessage(Locale.getDefault(),
key, new Object [] {identifier}));
}
|
public java.lang.Object | getProperty(java.lang.String name)
if (name == null) {
throw new NullPointerException();
}
try {
return fComponentManager.getProperty(name);
}
catch (XMLConfigurationException e) {
final String identifier = e.getIdentifier();
final String key = e.getType() == XMLConfigurationException.NOT_RECOGNIZED ?
"property-not-recognized" : "property-not-supported";
throw new SAXNotRecognizedException(
SAXMessageFormatter.formatMessage(Locale.getDefault(),
key, new Object [] {identifier}));
}
|
public org.w3c.dom.ls.LSResourceResolver | getResourceResolver()
return fComponentManager.getResourceResolver();
|
public javax.xml.validation.TypeInfoProvider | getTypeInfoProvider()
return fTypeInfoProvider;
|
public void | ignorableWhitespace(com.sun.org.apache.xerces.internal.xni.XMLString text, com.sun.org.apache.xerces.internal.xni.Augmentations augs)
if (fContentHandler != null) {
try {
fContentHandler.ignorableWhitespace(text.ch, text.offset, text.length);
}
catch (SAXException e) {
throw new XNIException(e);
}
}
|
public void | ignorableWhitespace(char[] ch, int start, int length)
try {
fTempString.setValues(ch, start, length);
fSchemaValidator.ignorableWhitespace(fTempString, null);
}
catch (XMLParseException e) {
throw Util.toSAXParseException(e);
}
catch (XNIException e) {
throw Util.toSAXException(e);
}
|
public boolean | isEntityDeclared(java.lang.String name)
return false;
|
public boolean | isEntityUnparsed(java.lang.String name)
if (fUnparsedEntities != null) {
return fUnparsedEntities.containsKey(name);
}
return false;
|
public void | notationDecl(java.lang.String name, java.lang.String publicId, java.lang.String systemId)
|
public void | processingInstruction(java.lang.String target, com.sun.org.apache.xerces.internal.xni.XMLString data, com.sun.org.apache.xerces.internal.xni.Augmentations augs)
if (fContentHandler != null) {
try {
fContentHandler.processingInstruction(target, data.toString());
}
catch (SAXException e) {
throw new XNIException(e);
}
}
|
public void | processingInstruction(java.lang.String target, java.lang.String data)
/**
* Processing instructions do not participate in schema validation,
* so just forward the event to the application's content
* handler.
*/
if (fContentHandler != null) {
fContentHandler.processingInstruction(target, data);
}
|
public void | setContentHandler(org.xml.sax.ContentHandler receiver)
fContentHandler = receiver;
|
public void | setDocumentLocator(org.xml.sax.Locator locator)
fSAXLocatorWrapper.setLocator(locator);
if (fContentHandler != null) {
fContentHandler.setDocumentLocator(locator);
}
|
public void | setDocumentSource(com.sun.org.apache.xerces.internal.xni.parser.XMLDocumentSource source)
|
public void | setErrorHandler(org.xml.sax.ErrorHandler errorHandler)
fComponentManager.setErrorHandler(errorHandler);
|
public void | setFeature(java.lang.String name, boolean value)
if (name == null) {
throw new NullPointerException();
}
try {
fComponentManager.setFeature(name, value);
}
catch (XMLConfigurationException e) {
final String identifier = e.getIdentifier();
final String key = e.getType() == XMLConfigurationException.NOT_RECOGNIZED ?
"feature-not-recognized" : "feature-not-supported";
throw new SAXNotRecognizedException(
SAXMessageFormatter.formatMessage(Locale.getDefault(),
key, new Object [] {identifier}));
}
|
public void | setProperty(java.lang.String name, java.lang.Object object)
if (name == null) {
throw new NullPointerException();
}
try {
fComponentManager.setProperty(name, object);
}
catch (XMLConfigurationException e) {
final String identifier = e.getIdentifier();
final String key = e.getType() == XMLConfigurationException.NOT_RECOGNIZED ?
"property-not-recognized" : "property-not-supported";
throw new SAXNotRecognizedException(
SAXMessageFormatter.formatMessage(Locale.getDefault(),
key, new Object [] {identifier}));
}
|
public void | setResourceResolver(org.w3c.dom.ls.LSResourceResolver resourceResolver)
fComponentManager.setResourceResolver(resourceResolver);
|
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.
if (fContentHandler != null) {
fContentHandler.skippedEntity(name);
}
|
public void | startCDATA(com.sun.org.apache.xerces.internal.xni.Augmentations augs)
|
public void | startDocument(com.sun.org.apache.xerces.internal.xni.XMLLocator locator, java.lang.String encoding, com.sun.org.apache.xerces.internal.xni.NamespaceContext namespaceContext, com.sun.org.apache.xerces.internal.xni.Augmentations augs)
if (fContentHandler != null) {
try {
fContentHandler.startDocument();
}
catch (SAXException e) {
throw new XNIException(e);
}
}
|
public void | startDocument()
fComponentManager.reset();
fSchemaValidator.setDocumentHandler(this);
fValidationManager.setEntityState(this);
fTypeInfoProvider.finishStartElement(); // cleans up TypeInfoProvider
fNeedPushNSContext = true;
if (fUnparsedEntities != null && !fUnparsedEntities.isEmpty()) {
// should only clear this if the last document contained unparsed entities
fUnparsedEntities.clear();
}
fErrorReporter.setDocumentLocator(fSAXLocatorWrapper);
try {
fSchemaValidator.startDocument(fSAXLocatorWrapper, fSAXLocatorWrapper.getEncoding(), fNamespaceContext, null);
}
catch (XMLParseException e) {
throw Util.toSAXParseException(e);
}
catch (XNIException e) {
throw Util.toSAXException(e);
}
|
public void | startElement(com.sun.org.apache.xerces.internal.xni.QName element, com.sun.org.apache.xerces.internal.xni.XMLAttributes attributes, com.sun.org.apache.xerces.internal.xni.Augmentations augs)
if (fContentHandler != null) {
try {
fTypeInfoProvider.beginStartElement(augs, attributes);
fContentHandler.startElement((element.uri != null) ? element.uri : XMLSymbols.EMPTY_STRING,
element.localpart, element.rawname, fAttrAdapter);
}
catch (SAXException e) {
throw new XNIException(e);
}
finally {
fTypeInfoProvider.finishStartElement();
}
}
|
public void | startElement(java.lang.String uri, java.lang.String localName, java.lang.String qName, org.xml.sax.Attributes atts)
if (fNeedPushNSContext) {
fNamespaceContext.pushContext();
}
fNeedPushNSContext = true;
// Fill element QName
fillQName(fElementQName, uri, localName, qName);
// Fill XMLAttributes
if (atts instanceof Attributes2) {
fillXMLAttributes2((Attributes2) atts);
}
else {
fillXMLAttributes(atts);
}
try {
fSchemaValidator.startElement(fElementQName, fAttributes, null);
}
catch (XMLParseException e) {
throw Util.toSAXParseException(e);
}
catch (XNIException e) {
throw Util.toSAXException(e);
}
|
public void | startGeneralEntity(java.lang.String name, com.sun.org.apache.xerces.internal.xni.XMLResourceIdentifier identifier, java.lang.String encoding, com.sun.org.apache.xerces.internal.xni.Augmentations augs)
|
public void | startPrefixMapping(java.lang.String prefix, java.lang.String uri)
String prefixSymbol;
String uriSymbol;
if (!fStringsInternalized) {
prefixSymbol = (prefix != null) ? fSymbolTable.addSymbol(prefix) : XMLSymbols.EMPTY_STRING;
uriSymbol = (uri != null && uri.length() > 0) ? fSymbolTable.addSymbol(uri) : null;
}
else {
prefixSymbol = (prefix != null) ? prefix : XMLSymbols.EMPTY_STRING;
uriSymbol = (uri != null && uri.length() > 0) ? uri : null;
}
if (fNeedPushNSContext) {
fNeedPushNSContext = false;
fNamespaceContext.pushContext();
}
fNamespaceContext.declarePrefix(prefixSymbol, uriSymbol);
if (fContentHandler != null) {
fContentHandler.startPrefixMapping(prefix, uri);
}
|
public void | textDecl(java.lang.String version, java.lang.String encoding, com.sun.org.apache.xerces.internal.xni.Augmentations augs)
|
public void | unparsedEntityDecl(java.lang.String name, java.lang.String publicId, java.lang.String systemId, java.lang.String notationName)
if (fUnparsedEntities == null) {
fUnparsedEntities = new HashMap();
}
fUnparsedEntities.put(name, name);
|
public void | validate(javax.xml.transform.Source source, javax.xml.transform.Result result)
if (result instanceof SAXResult || result == null) {
final SAXSource saxSource = (SAXSource) source;
final SAXResult saxResult = (SAXResult) result;
if (result != null) {
setContentHandler(saxResult.getHandler());
}
try {
XMLReader reader = saxSource.getXMLReader();
if( reader==null ) {
// create one now
SAXParserFactory spf = SAXParserFactory.newInstance();
spf.setNamespaceAware(true);
try {
reader = spf.newSAXParser().getXMLReader();
// If this is a Xerces SAX parser, set the security manager if there is one
if (reader instanceof com.sun.org.apache.xerces.internal.parsers.SAXParser) {
SecurityManager securityManager = (SecurityManager) fComponentManager.getProperty(SECURITY_MANAGER);
if (securityManager != null) {
try {
reader.setProperty(SECURITY_MANAGER, securityManager);
}
// Ignore the exception if the security manager cannot be set.
catch (SAXException exc) {}
}
}
} catch( Exception e ) {
// this is impossible, but better safe than sorry
throw new FactoryConfigurationError(e);
}
}
// If XML names and Namespace URIs are already internalized we
// can avoid running them through the SymbolTable.
try {
fStringsInternalized = reader.getFeature(STRING_INTERNING);
}
catch (SAXException exc) {
// The feature isn't recognized or getting it is not supported.
// In either case, assume that strings are not internalized.
fStringsInternalized = false;
}
ErrorHandler errorHandler = fComponentManager.getErrorHandler();
reader.setErrorHandler(errorHandler != null ? errorHandler : DraconianErrorHandler.getInstance());
reader.setEntityResolver(fResolutionForwarder);
fResolutionForwarder.setEntityResolver(fComponentManager.getResourceResolver());
reader.setContentHandler(this);
reader.setDTDHandler(this);
InputSource is = saxSource.getInputSource();
reader.parse(is);
}
finally {
// release the reference to user's handler ASAP
setContentHandler(null);
}
return;
}
throw new IllegalArgumentException(JAXPValidationMessageFormatter.formatMessage(Locale.getDefault(),
"SourceResultMismatch",
new Object [] {source.getClass().getName(), result.getClass().getName()}));
|
public void | xmlDecl(java.lang.String version, java.lang.String encoding, java.lang.String standalone, com.sun.org.apache.xerces.internal.xni.Augmentations augs)
|