com.sun.xml.internal.rngom.ast.builder.BuildException Java Examples

The following examples show how to use com.sun.xml.internal.rngom.ast.builder.BuildException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SchemaBuilderImpl.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public DataPatternBuilder makeDataPatternBuilder(String datatypeLibrary, String type, Location loc)
        throws BuildException {
    DatatypeLibrary dl = datatypeLibraryFactory.createDatatypeLibrary(datatypeLibrary);
    if (dl == null) {
        error("unrecognized_datatype_library", datatypeLibrary, (Locator) loc);
    } else {
        try {
            return new DataPatternBuilderImpl(dl.createDatatypeBuilder(type));
        } catch (DatatypeException e) {
            String detail = e.getMessage();
            if (detail != null) {
                error("unsupported_datatype_detail", datatypeLibrary, type, detail, (Locator) loc);
            } else {
                error("unrecognized_datatype", datatypeLibrary, type, (Locator) loc);
            }
        }
    }
    return new DummyDataPatternBuilder();
}
 
Example #2
Source File: SchemaBuilderHost.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public ParsedPattern makeChoice(List patterns,
    Location _loc, Annotations _anno) throws BuildException {

    List<ParsedPattern> lp = new ArrayList<ParsedPattern>();
    List<ParsedPattern> rp = new ArrayList<ParsedPattern>();
    for( int i=0; i<patterns.size(); i++ ) {
        lp.add( ((ParsedPatternHost)patterns.get(i)).lhs);
        rp.add( ((ParsedPatternHost)patterns.get(i)).rhs);
    }
    LocationHost loc = cast(_loc);
    AnnotationsHost anno = cast(_anno);

    return new ParsedPatternHost(
        lhs.makeChoice(lp, loc.lhs, anno.lhs),
        rhs.makeChoice(rp, loc.rhs, anno.rhs));
}
 
Example #3
Source File: SchemaBuilderImpl.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public ParsedPattern makeExternalRef(Parseable current, String uri, String ns, Scope scope,
        Location loc, Annotations anno)
        throws BuildException {
    for (OpenIncludes inc = openIncludes;
            inc != null;
            inc = inc.parent) {
        if (inc.uri.equals(uri)) {
            error("recursive_include", uri, (Locator) loc);
            return pb.makeError();
        }
    }
    try {
        return current.parseExternal(uri, new SchemaBuilderImpl(ns, uri, this), scope, ns);
    } catch (IllegalSchemaException e) {
        noteError();
        return pb.makeError();
    }
}
 
Example #4
Source File: SchemaBuilderHost.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public ParsedPattern makeGroup(List patterns,
    Location _loc, Annotations _anno) throws BuildException {

    List<ParsedPattern> lp = new ArrayList<ParsedPattern>();
    List<ParsedPattern> rp = new ArrayList<ParsedPattern>();
    for( int i=0; i<patterns.size(); i++ ) {
        lp.add( ((ParsedPatternHost)patterns.get(i)).lhs);
        rp.add( ((ParsedPatternHost)patterns.get(i)).rhs);
    }
    LocationHost loc = cast(_loc);
    AnnotationsHost anno = cast(_anno);

    return new ParsedPatternHost(
        lhs.makeGroup(lp, loc.lhs, anno.lhs),
        rhs.makeGroup(rp, loc.rhs, anno.rhs));
}
 
Example #5
Source File: SchemaBuilderImpl.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public void addParam(String name, String value, Context context, String ns, Location loc, Annotations anno)
        throws BuildException {
    try {
        dtb.addParameter(name, value, new ValidationContextImpl(context, ns));
    } catch (DatatypeException e) {
        String detail = e.getMessage();
        int pos = e.getIndex();
        String displayedParam;
        if (pos == DatatypeException.UNKNOWN) {
            displayedParam = null;
        } else {
            displayedParam = displayParam(value, pos);
        }
        if (displayedParam != null) {
            if (detail != null) {
                error("invalid_param_detail_display", detail, displayedParam, (Locator) loc);
            } else {
                error("invalid_param_display", displayedParam, (Locator) loc);
            }
        } else if (detail != null) {
            error("invalid_param_detail", detail, (Locator) loc);
        } else {
            error("invalid_param", (Locator) loc);
        }
    }
}
 
Example #6
Source File: SchemaBuilderHost.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public ParsedPattern makeOptional(ParsedPattern _p, Location _loc,
    Annotations _anno) throws BuildException {

    ParsedPatternHost p = (ParsedPatternHost) _p;
    LocationHost loc = cast(_loc);
    AnnotationsHost anno = cast(_anno);

    return new ParsedPatternHost(
        lhs.makeOptional(p.lhs, loc.lhs, anno.lhs),
        rhs.makeOptional(p.rhs, loc.rhs, anno.rhs));
}
 
Example #7
Source File: GrammarBuilderImpl.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public void define(String name, Combine combine, ParsedPattern pattern, Location loc, Annotations anno) throws BuildException {
    if(name==START) {
        grammar.start = (DPattern)pattern;
    } else {
        // TODO: handle combine
        DDefine d = grammar.getOrAdd(name);
        d.setPattern( (DPattern) pattern );
        if (anno!=null) {
            d.annotation = ((Annotation)anno).getResult();
        }
    }
}
 
Example #8
Source File: SchemaBuilderHost.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public ParsedPattern annotateAfter(ParsedPattern _p,
    ParsedElementAnnotation _e) throws BuildException {

    ParsedPatternHost p = (ParsedPatternHost) _p;
    ParsedElementAnnotationHost e = (ParsedElementAnnotationHost) _e;
    return new ParsedPatternHost(
        lhs.annotateAfter(p.lhs, e.lhs),
        rhs.annotateAfter(p.rhs, e.rhs));
}
 
Example #9
Source File: DataPatternBuilderHost.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public void addParam(String name, String value, Context context, String ns, Location _loc, Annotations _anno) throws BuildException {
    LocationHost loc = cast(_loc);
    AnnotationsHost anno = cast(_anno);

    lhs.addParam( name, value, context, ns, loc.lhs, anno.lhs );
    rhs.addParam( name, value, context, ns, loc.rhs, anno.rhs );
}
 
Example #10
Source File: GrammarSectionHost.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public void define(String name, Combine combine, ParsedPattern _pattern,
    Location _loc, Annotations _anno) throws BuildException {
    ParsedPatternHost pattern = (ParsedPatternHost) _pattern;
    LocationHost loc = cast(_loc);
    AnnotationsHost anno = cast(_anno);

    lhs.define(name, combine, pattern.lhs, loc.lhs, anno.lhs);
    rhs.define(name, combine, pattern.rhs, loc.rhs, anno.rhs);
}
 
Example #11
Source File: DivHost.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public void endDiv(Location _loc, Annotations _anno) throws BuildException {
    LocationHost loc = cast(_loc);
    AnnotationsHost anno = cast(_anno);

    lhs.endDiv( loc.lhs, anno.lhs );
    rhs.endDiv( loc.rhs, anno.rhs );
}
 
Example #12
Source File: ElementAnnotationBuilderHost.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public void addText(String value, Location _loc, CommentList _comments) throws BuildException {
    LocationHost loc = cast(_loc);
    CommentListHost comments = (CommentListHost) _comments;

    lhs.addText( value, loc.lhs, comments==null?null:comments.lhs );
    rhs.addText( value, loc.rhs, comments==null?null:comments.rhs );
}
 
Example #13
Source File: SchemaBuilderHost.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public DataPatternBuilder makeDataPatternBuilder(String datatypeLibrary,
    String type, Location _loc) throws BuildException {
    LocationHost loc = cast(_loc);

    return new DataPatternBuilderHost(
        lhs.makeDataPatternBuilder(datatypeLibrary, type, loc.lhs),
        rhs.makeDataPatternBuilder(datatypeLibrary, type, loc.rhs) );
}
 
Example #14
Source File: CompactSyntax.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
private void reportEscapeSyntaxException(EscapeSyntaxException e) {
  if (eh != null) {
    LocatorImpl loc = new LocatorImpl();
    loc.setLineNumber(e.getLineNumber());
    loc.setColumnNumber(e.getColumnNumber());
    loc.setSystemId(sourceUri);
    try {
      eh.error(new SAXParseException(localizer.message(e.getKey()), loc));
    }
    catch (SAXException se) {
      throw new BuildException(se);
    }
  }
}
 
Example #15
Source File: SchemaBuilderImpl.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public void endInclude(Parseable current, String uri, String ns,
        Location loc, Annotations anno) throws BuildException {
    for (OpenIncludes inc = sb.openIncludes;
            inc != null;
            inc = inc.parent) {
        if (inc.uri.equals(uri)) {
            sb.error("recursive_include", uri, (Locator) loc);
            return;
        }
    }

    for (Override o = overrides; o != null; o = o.next) {
        o.replacementStatus = o.prp.getReplacementStatus();
        o.prp.setReplacementStatus(RefPattern.REPLACEMENT_REQUIRE);
    }
    try {
        SchemaBuilderImpl isb = new SchemaBuilderImpl(ns, uri, sb);
        current.parseInclude(uri, isb, new GrammarImpl(isb, grammar), ns);
        for (Override o = overrides; o != null; o = o.next) {
            if (o.prp.getReplacementStatus() == RefPattern.REPLACEMENT_REQUIRE) {
                if (o.prp.getName() == null) {
                    sb.error("missing_start_replacement", (Locator) loc);
                } else {
                    sb.error("missing_define_replacement", o.prp.getName(), (Locator) loc);
                }
            }
        }
    } catch (IllegalSchemaException e) {
        sb.noteError();
    } finally {
        for (Override o = overrides; o != null; o = o.next) {
            o.prp.setReplacementStatus(o.replacementStatus);
        }
    }
}
 
Example #16
Source File: SchemaBuilderHost.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public ParsedPattern makeList(ParsedPattern _p, Location _loc,
    Annotations _anno) throws BuildException {

    ParsedPatternHost p = (ParsedPatternHost) _p;
    LocationHost loc = cast(_loc);
    AnnotationsHost anno = cast(_anno);

    return new ParsedPatternHost(
        lhs.makeList(p.lhs, loc.lhs, anno.lhs),
        rhs.makeList(p.rhs, loc.rhs, anno.rhs));
}
 
Example #17
Source File: ScopeHost.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public ParsedPattern makeParentRef(String name, Location _loc, Annotations _anno) throws BuildException {
    LocationHost loc = cast(_loc);
    AnnotationsHost anno = cast(_anno);

    return new ParsedPatternHost(
        lhs.makeParentRef(name, loc.lhs, anno.lhs),
        rhs.makeParentRef(name, loc.rhs, anno.rhs));
}
 
Example #18
Source File: CommentListHost.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public void addComment(String value, Location _loc) throws BuildException {
    LocationHost loc = cast(_loc);
    if(lhs!=null)
        lhs.addComment(value,loc.lhs);
    if(rhs!=null)
        rhs.addComment(value,loc.rhs);
}
 
Example #19
Source File: GrammarBuilderImpl.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public ParsedPattern endGrammar(Location loc, Annotations anno) throws BuildException {
    // Harshit : Fixed possible NPE and issue in handling of annotations
    if (anno != null) {
        if (grammar.annotation != null) {
            grammar.annotation.contents.addAll(((Annotation) anno).getResult().contents);
        }
    }
    return grammar;
}
 
Example #20
Source File: SchemaBuilderHost.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public ParsedPattern makeAttribute(ParsedNameClass _nc, ParsedPattern _p,
    Location _loc, Annotations _anno) throws BuildException {

    ParsedNameClassHost nc = (ParsedNameClassHost) _nc;
    ParsedPatternHost p = (ParsedPatternHost) _p;
    LocationHost loc = cast(_loc);
    AnnotationsHost anno = cast(_anno);

    return new ParsedPatternHost(
        lhs.makeAttribute(nc.lhs, p.lhs, loc.lhs, anno.lhs),
        rhs.makeAttribute(nc.rhs, p.rhs, loc.rhs, anno.rhs));
}
 
Example #21
Source File: GrammarBuilderImpl.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public void topLevelAnnotation(ParsedElementAnnotation ea) throws BuildException {
    // Harshit : Fixed issue in handling of annotations
    if (additionalElementAnnotations==null) {
        additionalElementAnnotations = new ArrayList<Element>();
    }
    additionalElementAnnotations.add(((ElementWrapper)ea).element);
    if (grammar.annotation==null) {
        grammar.annotation = new DAnnotation();
    }
    grammar.annotation.contents.addAll(additionalElementAnnotations);
}
 
Example #22
Source File: SchemaBuilderImpl.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public ParsedPattern makePattern(ParsedPattern except, Location loc, Annotations anno)
        throws BuildException {
    try {
        return pb.makeDataExcept(dtb.createDatatype(), (Pattern) except, (Locator) loc);
    } catch (DatatypeException e) {
        String detail = e.getMessage();
        if (detail != null) {
            error("invalid_params_detail", detail, (Locator) loc);
        } else {
            error("invalid_params", (Locator) loc);
        }
        return pb.makeError();
    }
}
 
Example #23
Source File: SchemaBuilderImpl.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public ParsedPattern makePattern(Location loc, Annotations anno)
        throws BuildException {
    try {
        return pb.makeData(dtb.createDatatype());
    } catch (DatatypeException e) {
        String detail = e.getMessage();
        if (detail != null) {
            error("invalid_params_detail", detail, (Locator) loc);
        } else {
            error("invalid_params", (Locator) loc);
        }
        return pb.makeError();
    }
}
 
Example #24
Source File: IncludeImpl.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void define(String name, Combine combine, ParsedPattern pattern, Location loc, Annotations anno) throws BuildException {
    // check for overridden pattern
    if(name==START) {
        if(startOverriden)
            return;
    } else {
        if(overridenPatterns.contains(name))
            return;
    }
    // otherwise define
    super.define(name, combine, pattern, loc, anno);
}
 
Example #25
Source File: NameClassBuilderHost.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public ParsedNameClass annotateAfter(ParsedNameClass _nc, ParsedElementAnnotation _e) throws BuildException {
    ParsedNameClassHost nc = (ParsedNameClassHost) _nc;
    ParsedElementAnnotationHost e = (ParsedElementAnnotationHost) _e;

    return new ParsedNameClassHost(
        lhs.annotateAfter(nc.lhs, e.lhs),
        rhs.annotateAfter(nc.rhs, e.rhs));
}
 
Example #26
Source File: GrammarHost.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public ParsedPattern endGrammar(Location _loc, Annotations _anno) throws BuildException {
    LocationHost loc = cast(_loc);
    AnnotationsHost anno = cast(_anno);

    return new ParsedPatternHost(
        lhs.endGrammar(loc.lhs, anno.lhs),
        rhs.endGrammar(loc.rhs, anno.rhs));
}
 
Example #27
Source File: SchemaBuilderImpl.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public ParsedPattern makeGroup(List patterns, Location loc, Annotations anno)
        throws BuildException {
    if (patterns.isEmpty()) {
        throw new IllegalArgumentException();
    }
    Pattern result = (Pattern) patterns.get(0);
    for (int i = 1; i < patterns.size(); i++) {
        result = pb.makeGroup(result, (Pattern) patterns.get(i));
    }
    return result;
}
 
Example #28
Source File: DataPatternBuilderImpl.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public ParsedPattern makePattern(ParsedPattern except, Location loc, Annotations anno) throws BuildException {
    p.except = (DPattern)except;
    if (anno!=null) {
        p.annotation = ((Annotation)anno).getResult();
    }
    return p;
}
 
Example #29
Source File: SchemaBuilderImpl.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public ParsedPattern makeChoice(List patterns, Location loc, Annotations anno)
        throws BuildException {
    if (patterns.isEmpty()) {
        throw new IllegalArgumentException();
    }
    Pattern result = (Pattern) patterns.get(0);
    for (int i = 1; i < patterns.size(); i++) {
        result = pb.makeChoice(result, (Pattern) patterns.get(i));
    }
    return result;
}
 
Example #30
Source File: DataPatternBuilderHost.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public ParsedPattern makePattern(ParsedPattern _except, Location _loc, Annotations _anno) throws BuildException {
    ParsedPatternHost except = (ParsedPatternHost) _except;
    LocationHost loc = cast(_loc);
    AnnotationsHost anno = cast(_anno);

    return new ParsedPatternHost(
        lhs.makePattern(except.lhs, loc.lhs, anno.lhs),
        rhs.makePattern(except.rhs, loc.rhs, anno.rhs));
}