| Method from com.sun.xml.internal.xsom.impl.parser.NGCCRuntimeEx Detail: |
public void addPatcher(Patch patcher) {
parser.patcherManager.addPatcher(patcher);
}
|
public void checkDoubleDefError(XSDeclaration c) throws SAXException {
if(c==null) return;
reportError( Messages.format(Messages.ERR_DOUBLE_DEFINITION,c.getName()) );
reportError( Messages.format(Messages.ERR_DOUBLE_DEFINITION_ORIGINAL), c.getLocator() );
}
|
public Locator copyLocator() {
return new LocatorImpl(getLocator());
}
Creates a copy of the current locator object. |
public AnnotationParser createAnnotationParser() {
if(parser.getAnnotationParserFactory()==null)
return DefaultAnnotationParser.theInstance;
else
return parser.getAnnotationParserFactory().create();
}
Creates a new instance of annotation parser. |
public ValidationContext createValidationContext() {
return currentContext;
}
Returns an immutable snapshot of the current context. |
public XmlString createXmlString(String value) {
if(value==null) return null;
else return new XmlString(value,createValidationContext());
}
|
public void endPrefixMapping(String prefix) throws SAXException {
super.endPrefixMapping(prefix);
currentContext = currentContext.previous;
}
|
public String getAnnotationContextElementName() {
return elementNames.get( elementNames.size()-2 );
}
Gets the element name that contains the annotation element.
This method works correctly only when called by the annotation handler. |
public ErrorHandler getErrorHandler() {
return parser.errorHandler;
}
|
public boolean hasAlreadyBeenRead() {
if( documentSystemId!=null ) {
if( documentSystemId.startsWith("file:///") )
// change file:///abc to file:/abc
// JDK File.toURL method produces the latter, but according to RFC
// I don't think that's a valid URL. Since two different ways of
// producing URLs could produce those two different forms,
// we need to canonicalize one to the other.
documentSystemId = "file:/"+documentSystemId.substring(8);
} else {
// if the system Id is not provided, we can't test the identity,
// so we have no choice but to read it.
// the newly created SchemaDocumentImpl will be unique one
}
assert document ==null;
document = new SchemaDocumentImpl( currentSchema, documentSystemId );
SchemaDocumentImpl existing = parser.parsedDocuments.get(document);
if(existing==null) {
parser.parsedDocuments.put(document,document);
} else {
document = existing;
}
assert document !=null;
if(referer!=null) {
assert referer.document !=null : "referer "+referer.documentSystemId+" has docIdentity==null";
referer.document.references.add(this.document);
this.document.referers.add(referer.document);
}
return existing!=null;
}
Called when a new document is being parsed and checks
if the document has already been parsed before.
Used to avoid recursive inclusion. Note that the same
document will be parsed multiple times if they are for different
target namespaces.
Document Graph Model
The challenge we are facing here is that you have a graph of
documents that reference each other. Each document has an unique
URI to identify themselves, and references are done by using those.
The graph may contain cycles.
Our goal here is to parse all the documents in the graph, without
parsing the same document twice. This method implements this check.
One complication is the chameleon schema; a document can be parsed
multiple times if they are under different target namespaces.
Also, note that when you resolve relative URIs in the @schemaLocation,
their base URI is *NOT* the URI of the document. |
public void importSchema(String ns,
String schemaLocation) throws SAXException {
NGCCRuntimeEx newRuntime = new NGCCRuntimeEx(parser,false,this);
InputSource source = resolveRelativeURL(ns,schemaLocation);
if(source!=null)
newRuntime.parseEntity( source, false, ns, getLocator() );
// if source == null,
// we can't locate this document. Let's just hope that
// we already have the schema components for this schema
// or we will receive them in the future.
}
Imports the specified schema. |
public void includeSchema(String schemaLocation) throws SAXException {
NGCCRuntimeEx runtime = new NGCCRuntimeEx(parser,chameleonMode,this);
runtime.currentSchema = this.currentSchema;
runtime.blockDefault = this.blockDefault;
runtime.finalDefault = this.finalDefault;
if( schemaLocation==null ) {
SAXParseException e = new SAXParseException(
Messages.format( Messages.ERR_MISSING_SCHEMALOCATION ), getLocator() );
parser.errorHandler.fatalError(e);
throw e;
}
runtime.parseEntity( resolveRelativeURL(null,schemaLocation),
true, currentSchema.getTargetNamespace(), getLocator() );
}
Includes the specified schema. |
public void onEnterElementConsumed(String uri,
String localName,
String qname,
Attributes atts) throws SAXException {
super.onEnterElementConsumed(uri, localName, qname, atts);
elementNames.push(localName);
}
|
public void onLeaveElementConsumed(String uri,
String localName,
String qname) throws SAXException {
super.onLeaveElementConsumed(uri, localName, qname);
elementNames.pop();
}
|
public boolean parseBoolean(String v) {
if(v==null) return false;
v=v.trim();
return v.equals("true") || v.equals("1");
}
|
public void parseEntity(InputSource source,
boolean includeMode,
String expectedNamespace,
Locator importLocation) throws SAXException {
documentSystemId = source.getSystemId();
// System.out.println("parsing "+baseUri);
try {
Schema s = new Schema(this,includeMode,expectedNamespace);
setRootHandler(s);
try {
parser.parser.parse(source,this,
getErrorHandler(),
parser.getEntityResolver());
} catch( IOException e ) {
SAXParseException se = new SAXParseException(
e.toString(),importLocation,e);
parser.errorHandler.fatalError(se);
throw se;
}
} catch( SAXException e ) {
parser.setErrorFlag();
throw e;
}
}
Parses the specified entity. |
public ForeignAttributesImpl parseForeignAttributes(ForeignAttributesImpl next) {
ForeignAttributesImpl impl = new ForeignAttributesImpl(createValidationContext(),copyLocator(),next);
Attributes atts = getCurrentAttributes();
for( int i=0; i< atts.getLength(); i++ ) {
if(atts.getURI(i).length() >0) {
impl.addAttribute(
atts.getURI(i),
atts.getLocalName(i),
atts.getQName(i),
atts.getType(i),
atts.getValue(i)
);
}
}
return impl;
}
|
public UName parseUName(String qname) throws SAXException {
int idx = qname.indexOf(':");
if(idx< 0) {
String uri = resolveNamespacePrefix("");
// chamelon behavior. ugly...
if( uri.equals("") && chameleonMode )
uri = currentSchema.getTargetNamespace();
// this is guaranteed to resolve
return new UName(uri,qname,qname);
} else {
String prefix = qname.substring(0,idx);
String uri = currentContext.resolveNamespacePrefix(prefix);
if(uri==null) {
// prefix failed to resolve.
reportError(Messages.format(
Messages.ERR_UNDEFINED_PREFIX,prefix));
uri="undefined"; // replace with a dummy
}
return new UName( uri, qname.substring(idx+1), qname );
}
}
Parses UName under the given context. |
public void reportError(String msg) throws SAXException {
reportError(msg,getLocator());
}
|
public void reportError(String msg,
Locator loc) throws SAXException {
parser.patcherManager.reportError(msg,loc);
}
|
public void startPrefixMapping(String prefix,
String uri) throws SAXException {
super.startPrefixMapping(prefix,uri);
currentContext = new Context(prefix,uri,currentContext);
}
|
protected void unexpectedX(String token) throws SAXException {
SAXParseException e = new SAXParseException(MessageFormat.format(
"Unexpected {0} appears at line {1} column {2}",
token,
getLocator().getLineNumber(),
getLocator().getColumnNumber()),
getLocator());
parser.errorHandler.fatalError(e);
throw e; // we will abort anyway
}
|