Fields Summary |
---|
private SymbolTable | fSymbolTableSymbol table |
private SchemaDOMParser | fSchemaDOMParserSchemaDOMParser, events will be delegated to SchemaDOMParser to pass |
private final SAXLocatorWrapper | fSAXLocatorWrapperXML Locator wrapper for SAX. |
private NamespaceSupport | fNamespaceContextThe namespace context of this document: stores namespaces in scope |
private boolean | fNeedPushNSContextIndicate if push NamespaceContest is needed |
private boolean | fNamespacePrefixesFlag used to track whether namespace declarations are reported as attributes. |
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 XMLString | fTempString |
Methods Summary |
---|
private void | addNamespaceDeclarations(int prefixCount)
String prefix = null;
String localpart = null;
String rawname = null;
String nsPrefix = null;
String nsURI = null;
for (int i = 0; i < prefixCount; ++i) {
nsPrefix = fNamespaceContext.getDeclaredPrefixAt(i);
nsURI = fNamespaceContext.getURI(nsPrefix);
if (nsPrefix.length() > 0) {
prefix = XMLSymbols.PREFIX_XMLNS;
localpart = nsPrefix;
rawname = fSymbolTable.addSymbol(prefix + ":" + localpart);
}
else {
prefix = XMLSymbols.EMPTY_STRING;
localpart = XMLSymbols.PREFIX_XMLNS;
rawname = XMLSymbols.PREFIX_XMLNS;
}
fAttributeQName.setValues(prefix, localpart, rawname, NamespaceContext.XMLNS_URI);
fAttributes.addAttribute(fAttributeQName, XMLSymbols.fCDATASymbol, nsURI);
}
|
public void | characters(char[] ch, int start, int length)
try {
fTempString.setValues(ch, start, length);
fSchemaDOMParser.characters(fTempString, null);
}
catch (XMLParseException e) {
convertToSAXParseException(e);
}
catch (XNIException e) {
convertToSAXException(e);
}
|
static void | convertToSAXException(com.sun.org.apache.xerces.internal.xni.XNIException e)
Exception ex = e.getException();
if (ex == null) {
throw new SAXException(e.getMessage());
}
if (ex instanceof SAXException) {
throw (SAXException) ex;
}
throw new SAXException(ex);
|
static void | convertToSAXParseException(com.sun.org.apache.xerces.internal.xni.parser.XMLParseException e)
Exception ex = e.getException();
if (ex == null) {
// must be a parser exception; mine it for locator info and throw
// a SAXParseException
LocatorImpl locatorImpl = new LocatorImpl();
locatorImpl.setPublicId(e.getPublicId());
locatorImpl.setSystemId(e.getExpandedSystemId());
locatorImpl.setLineNumber(e.getLineNumber());
locatorImpl.setColumnNumber(e.getColumnNumber());
throw new SAXParseException(e.getMessage(), locatorImpl);
}
if (ex instanceof SAXException) {
// why did we create an XMLParseException?
throw (SAXException) ex;
}
throw new SAXException(ex);
|
public void | endDocument()
fSAXLocatorWrapper.setLocator(null);
try {
fSchemaDOMParser.endDocument(null);
}
catch (XMLParseException e) {
convertToSAXParseException(e);
}
catch (XNIException e) {
convertToSAXException(e);
}
|
public void | endElement(java.lang.String uri, java.lang.String localName, java.lang.String qName)
fillQName(fElementQName, uri, localName, qName);
try {
fSchemaDOMParser.endElement(fElementQName, null);
}
catch (XMLParseException e) {
convertToSAXParseException(e);
}
catch (XNIException e) {
convertToSAXException(e);
}
finally {
fNamespaceContext.popContext();
}
|
public void | endPrefixMapping(java.lang.String prefix)
// do nothing
|
private void | fillQName(com.sun.org.apache.xerces.internal.xni.QName toFill, java.lang.String uri, java.lang.String localpart, java.lang.String rawname)
if (!fStringsInternalized) {
uri = (uri != null && uri.length() > 0) ? fSymbolTable.addSymbol(uri) : null;
localpart = (localpart != null) ? fSymbolTable.addSymbol(localpart) : XMLSymbols.EMPTY_STRING;
rawname = (rawname != null) ? fSymbolTable.addSymbol(rawname) : XMLSymbols.EMPTY_STRING;
}
else {
if (uri != null && uri.length() == 0) {
uri = null;
}
if (localpart == null) {
localpart = XMLSymbols.EMPTY_STRING;
}
if (rawname == null) {
rawname = XMLSymbols.EMPTY_STRING;
}
}
String prefix = XMLSymbols.EMPTY_STRING;
int prefixIdx = rawname.indexOf(':");
if (prefixIdx != -1) {
prefix = fSymbolTable.addSymbol(rawname.substring(0, prefixIdx));
// local part may be an empty string if this is a namespace declaration
if (localpart == XMLSymbols.EMPTY_STRING) {
localpart = fSymbolTable.addSymbol(rawname.substring(prefixIdx + 1));
}
}
// local part may be an empty string if this is a namespace declaration
else if (localpart == XMLSymbols.EMPTY_STRING) {
localpart = rawname;
}
toFill.setValues(prefix, localpart, rawname, uri);
|
private void | fillXMLAttributes(org.xml.sax.Attributes atts)
fAttributes.removeAllAttributes();
final int attrCount = atts.getLength();
for (int i = 0; i < attrCount; ++i) {
fillQName(fAttributeQName, atts.getURI(i), atts.getLocalName(i), atts.getQName(i));
String type = atts.getType(i);
fAttributes.addAttributeNS(fAttributeQName, (type != null) ? type : XMLSymbols.fCDATASymbol, atts.getValue(i));
fAttributes.setSpecified(i, true);
}
|
public org.w3c.dom.Document | getDocument()
return fSchemaDOMParser.getDocument();
|
public void | ignorableWhitespace(char[] ch, int start, int length)
try {
fTempString.setValues(ch, start, length);
fSchemaDOMParser.ignorableWhitespace(fTempString, null);
}
catch (XMLParseException e) {
convertToSAXParseException(e);
}
catch (XNIException e) {
convertToSAXException(e);
}
|
public void | processingInstruction(java.lang.String target, java.lang.String data)
try {
fTempString.setValues(data.toCharArray(), 0, data.length());
fSchemaDOMParser.processingInstruction(target, fTempString, null);
}
catch (XMLParseException e) {
convertToSAXParseException(e);
}
catch (XNIException e) {
convertToSAXException(e);
}
|
public void | reset(com.sun.org.apache.xerces.internal.impl.xs.opti.SchemaDOMParser schemaDOMParser, com.sun.org.apache.xerces.internal.util.SymbolTable symbolTable, boolean namespacePrefixes, boolean stringsInternalized)
fSchemaDOMParser = schemaDOMParser;
fSymbolTable = symbolTable;
fNamespacePrefixes = namespacePrefixes;
fStringsInternalized = stringsInternalized;
|
public void | setDocumentLocator(org.xml.sax.Locator locator)
fSAXLocatorWrapper.setLocator(locator);
|
public void | skippedEntity(java.lang.String arg)
// do-nothing
|
public void | startDocument()
fNeedPushNSContext = true;
try {
fSchemaDOMParser.startDocument(fSAXLocatorWrapper, null, fNamespaceContext, null);
}
catch (XMLParseException e) {
convertToSAXParseException(e);
}
catch (XNIException e) {
convertToSAXException(e);
}
|
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 and XMLAttributes
fillQName(fElementQName, uri, localName, qName);
fillXMLAttributes(atts);
// Add namespace declarations if necessary
if (!fNamespacePrefixes) {
final int prefixCount = fNamespaceContext.getDeclaredPrefixCount();
if (prefixCount > 0) {
addNamespaceDeclarations(prefixCount);
}
}
try {
fSchemaDOMParser.startElement(fElementQName, fAttributes, null);
}
catch (XMLParseException e) {
convertToSAXParseException(e);
}
catch (XNIException e) {
convertToSAXException(e);
}
|
public void | startPrefixMapping(java.lang.String prefix, java.lang.String uri)
if (fNeedPushNSContext) {
fNeedPushNSContext = false;
fNamespaceContext.pushContext();
}
if (!fStringsInternalized) {
prefix = (prefix != null) ? fSymbolTable.addSymbol(prefix) : XMLSymbols.EMPTY_STRING;
uri = (uri != null && uri.length() > 0) ? fSymbolTable.addSymbol(uri) : null;
}
else {
if (prefix == null) {
prefix = XMLSymbols.EMPTY_STRING;
}
if (uri != null && uri.length() == 0) {
uri = null;
}
}
fNamespaceContext.declarePrefix(prefix, uri);
|