com.sun.xml.internal.rngom.ast.om.Location Java Examples

The following examples show how to use com.sun.xml.internal.rngom.ast.om.Location. 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 ParsedPattern endGrammar(Location loc, Annotations anno) throws BuildException {
    for (Enumeration e = defines.keys();
            e.hasMoreElements();) {
        String name = (String) e.nextElement();
        RefPattern rp = (RefPattern) defines.get(name);
        if (rp.getPattern() == null) {
            sb.error("reference_to_undefined", name, rp.getRefLocator());
            rp.setPattern(sb.pb.makeError());
        }
    }
    Pattern start = startRef.getPattern();
    if (start == null) {
        sb.error("missing_start_element", (Locator) loc);
        start = sb.pb.makeError();
    }
    return start;
}
 
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: SchemaParser.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public void startElement(String namespaceURI, String localName,
        String qName, Attributes atts) {
    flushText();
    if (builder != null) {
        builderStack.push(builder);
    }
    Location loc = makeLocation();
    builder = schemaBuilder.makeElementAnnotationBuilder(namespaceURI,
            localName,
            findPrefix(qName, namespaceURI),
            loc,
            getComments(),
            getContext());
    int len = atts.getLength();
    for (int i = 0; i < len; i++) {
        String uri = atts.getURI(i);
        builder.addAttribute(uri, atts.getLocalName(i), findPrefix(atts.getQName(i), uri),
                atts.getValue(i), loc);
    }
}
 
Example #4
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 #5
Source File: SchemaBuilderHost.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public ParsedPattern makeInterleave(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.makeInterleave(lp, loc.lhs, anno.lhs),
        rhs.makeInterleave(rp, loc.rhs, anno.rhs));
}
 
Example #6
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 #7
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 #8
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 #9
Source File: SchemaBuilderHost.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public ParsedPattern makeExternalRef(Parseable current, String uri,
    String ns, Scope _scope, Location _loc, Annotations _anno)
    throws BuildException, IllegalSchemaException {

    ScopeHost scope = (ScopeHost) _scope;
    LocationHost loc = cast(_loc);
    AnnotationsHost anno = cast(_anno);

    return new ParsedPatternHost(
        lhs.makeExternalRef(current, uri, ns, scope.lhs, loc.lhs, anno.lhs),
        rhs.makeExternalRef(current, uri, ns, scope.rhs, loc.rhs, anno.rhs) );
}
 
Example #10
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 #11
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 {
    super.define(name, combine, pattern, loc, anno);
    if(name==START)
        startOverriden = true;
    else
        overridenPatterns.add(name);
}
 
Example #12
Source File: DDataPattern.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public Param(String name, String value, Context context, String ns, Location loc, Annotation anno) {
    this.name = name;
    this.value = value;
    this.context = context;
    this.ns = ns;
    this.loc = loc;
    this.anno = anno;
}
 
Example #13
Source File: SchemaBuilderHost.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public ParsedPattern makeElement(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.makeElement(nc.lhs, p.lhs, loc.lhs, anno.lhs),
        rhs.makeElement(nc.rhs, p.rhs, loc.rhs, anno.rhs));
}
 
Example #14
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 #15
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 #16
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));
}
 
Example #17
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 #18
Source File: SchemaBuilderHost.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public ParsedPattern makeEmpty(Location _loc, Annotations _anno) {
    LocationHost loc = cast(_loc);
    AnnotationsHost anno = cast(_anno);

    return new ParsedPatternHost(
        lhs.makeEmpty(loc.lhs, anno.lhs),
        rhs.makeEmpty(loc.rhs, anno.rhs));
}
 
Example #19
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 #20
Source File: SchemaBuilderHost.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public ParsedPattern makeMixed(ParsedPattern _p, Location _loc,
    Annotations _anno) throws BuildException {

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

    return new ParsedPatternHost(
        lhs.makeMixed(p.lhs, loc.lhs, anno.lhs),
        rhs.makeMixed(p.rhs, loc.rhs, anno.rhs));
}
 
Example #21
Source File: SchemaBuilderHost.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public ElementAnnotationBuilder makeElementAnnotationBuilder(String ns,
    String localName, String prefix, Location _loc, CommentList _comments,
    Context context) {
    LocationHost loc = cast(_loc);
    CommentListHost comments = (CommentListHost) _comments;

    return new ElementAnnotationBuilderHost(
        lhs.makeElementAnnotationBuilder(ns, localName, prefix, loc.lhs, comments==null?null:comments.lhs, context),
        rhs.makeElementAnnotationBuilder(ns, localName, prefix, loc.rhs, comments==null?null:comments.rhs, context) );
}
 
Example #22
Source File: IncludeHost.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, IllegalSchemaException {
    LocationHost loc = cast(_loc);
    AnnotationsHost anno = cast(_anno);

    lhs.endInclude( current, uri, ns, loc.lhs, anno.lhs );
    rhs.endInclude( current, uri, ns, loc.rhs, anno.rhs );
}
 
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: SchemaBuilderHost.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public ParsedPattern makeZeroOrMore(ParsedPattern _p, Location _loc,
    Annotations _anno) throws BuildException {

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

    return new ParsedPatternHost(
        lhs.makeZeroOrMore(p.lhs, loc.lhs, anno.lhs),
        rhs.makeZeroOrMore(p.rhs, loc.rhs, anno.rhs));
}
 
Example #25
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 #26
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 #27
Source File: SchemaBuilderImpl.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 {
    // TODO: do this check by the caller
    if (parent == null) {
        sb.error("parent_ref_outside_grammar", (Locator) loc);
        return sb.makeErrorPattern();
    }
    return parent.makeRef(name, loc, anno);
}
 
Example #28
Source File: NameClassBuilderHost.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public ParsedNameClass makeAnyName(ParsedNameClass _except, Location _loc, Annotations _anno) {
    ParsedNameClassHost except = (ParsedNameClassHost) _except;
    LocationHost loc = cast(_loc);
    AnnotationsHost anno = cast(_anno);

    return new ParsedNameClassHost(
        lhs.makeAnyName( except.lhs, loc.lhs, anno.lhs ),
        rhs.makeAnyName( except.rhs, loc.rhs, anno.rhs ) );
}
 
Example #29
Source File: SchemaBuilderHost.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public ParsedPattern makeText(Location _loc, Annotations _anno) {
    LocationHost loc = cast(_loc);
    AnnotationsHost anno = cast(_anno);

    return new ParsedPatternHost(
        lhs.makeText(loc.lhs, anno.lhs),
        rhs.makeText(loc.rhs, anno.rhs));
}
 
Example #30
Source File: SchemaBuilderHost.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public ParsedPattern makeOneOrMore(ParsedPattern _p, Location _loc,
    Annotations _anno) throws BuildException {

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

    return new ParsedPatternHost(
        lhs.makeOneOrMore(p.lhs, loc.lhs, anno.lhs),
        rhs.makeOneOrMore(p.rhs, loc.rhs, anno.rhs));
}