com.sun.xml.xsom.impl.parser.BaseContentRef Maven / Gradle / Ivy
Go to download
XML Schema Object Model (XSOM) is a Java library that allows applications to easily parse XML Schema
documents and inspect information in them. It is expected to be useful for applications that need to take XML
Schema as an input.
package com.sun.xml.xsom.impl.parser;
import com.sun.xml.xsom.impl.Ref;
import com.sun.xml.xsom.XSContentType;
import com.sun.xml.xsom.XSType;
import org.xml.sax.Locator;
import org.xml.sax.SAXException;
public final class BaseContentRef implements Ref.ContentType, Patch {
private final Ref.Type baseType;
private final Locator loc;
public BaseContentRef(final NGCCRuntimeEx $runtime, Ref.Type _baseType) {
this.baseType = _baseType;
$runtime.addPatcher(this);
$runtime.addErrorChecker(new Patch() {
public void run() throws SAXException {
XSType t = baseType.getType();
if (t.isComplexType() && t.asComplexType().getContentType().asParticle()!=null) {
$runtime.reportError(
Messages.format(Messages.ERR_SIMPLE_CONTENT_EXPECTED,
t.getTargetNamespace(), t.getName()), loc);
}
}
});
this.loc = $runtime.copyLocator();
}
public XSContentType getContentType() {
XSType t = baseType.getType();
if(t.asComplexType()!=null)
return t.asComplexType().getContentType();
else
return t.asSimpleType();
}
public void run() throws SAXException {
if (baseType instanceof Patch)
((Patch) baseType).run();
}
}