com.sun.xml.internal.rngom.xml.util.WellKnownNamespaces Java Examples

The following examples show how to use com.sun.xml.internal.rngom.xml.util.WellKnownNamespaces. 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: CompatibilityDatatypeLibrary.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
public DatatypeBuilder createDatatypeBuilder(String type)
    throws DatatypeException {
    if (type.equals("ID")
        || type.equals("IDREF")
        || type.equals("IDREFS")) {
        if (xsdDatatypeLibrary == null) {
            xsdDatatypeLibrary =
                factory.createDatatypeLibrary(
                    WellKnownNamespaces.XML_SCHEMA_DATATYPES);
            if (xsdDatatypeLibrary == null)
                throw new DatatypeException();
        }
        return xsdDatatypeLibrary.createDatatypeBuilder(type);
    }
    throw new DatatypeException();
}
 
Example #2
Source File: DXMLPrinter.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public Void onGrammar(DGrammarPattern p) {
    start("grammar");
    ns(null, WellKnownNamespaces.RELAX_NG);
    on(p.getAnnotation());
    start("start");
    on(p.getStart());
    end();
    for (DDefine d : p) {
        start("define");
        attr("name", d.getName());
        on(d.getAnnotation());
        unwrapGroup(d.getPattern());
        end();
    }
    end();
    return null;
}
 
Example #3
Source File: CompatibilityDatatypeLibrary.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
public DatatypeBuilder createDatatypeBuilder(String type)
    throws DatatypeException {
    if (type.equals("ID")
        || type.equals("IDREF")
        || type.equals("IDREFS")) {
        if (xsdDatatypeLibrary == null) {
            xsdDatatypeLibrary =
                factory.createDatatypeLibrary(
                    WellKnownNamespaces.XML_SCHEMA_DATATYPES);
            if (xsdDatatypeLibrary == null)
                throw new DatatypeException();
        }
        return xsdDatatypeLibrary.createDatatypeBuilder(type);
    }
    throw new DatatypeException();
}
 
Example #4
Source File: RELAXNGCompiler.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
public RELAXNGCompiler(DPattern grammar, JCodeModel codeModel, Options opts) {
    this.grammar = grammar;
    this.opts = opts;
    this.model = new Model(opts,codeModel, NameConverter.smart,opts.classNameAllocator,null);

    datatypes.put("",DatatypeLib.BUILTIN);
    datatypes.put(WellKnownNamespaces.XML_SCHEMA_DATATYPES,DatatypeLib.XMLSCHEMA);

    // find all defines
    DefineFinder deff = new DefineFinder();
    grammar.accept(deff);
    this.defs = deff.defs;

    if(opts.defaultPackage2!=null)
        pkg = codeModel._package(opts.defaultPackage2);
    else
    if(opts.defaultPackage!=null)
        pkg = codeModel._package(opts.defaultPackage);
    else
        pkg = codeModel.rootPackage();
}
 
Example #5
Source File: RELAXNGCompiler.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
public RELAXNGCompiler(DPattern grammar, JCodeModel codeModel, Options opts) {
    this.grammar = grammar;
    this.opts = opts;
    this.model = new Model(opts,codeModel, NameConverter.smart,opts.classNameAllocator,null);

    datatypes.put("",DatatypeLib.BUILTIN);
    datatypes.put(WellKnownNamespaces.XML_SCHEMA_DATATYPES,DatatypeLib.XMLSCHEMA);

    // find all defines
    DefineFinder deff = new DefineFinder();
    grammar.accept(deff);
    this.defs = deff.defs;

    if(opts.defaultPackage2!=null)
        pkg = codeModel._package(opts.defaultPackage2);
    else
    if(opts.defaultPackage!=null)
        pkg = codeModel._package(opts.defaultPackage);
    else
        pkg = codeModel.rootPackage();
}
 
Example #6
Source File: RELAXNGCompiler.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
public RELAXNGCompiler(DPattern grammar, JCodeModel codeModel, Options opts) {
    this.grammar = grammar;
    this.opts = opts;
    this.model = new Model(opts,codeModel, NameConverter.smart,opts.classNameAllocator,null);

    datatypes.put("",DatatypeLib.BUILTIN);
    datatypes.put(WellKnownNamespaces.XML_SCHEMA_DATATYPES,DatatypeLib.XMLSCHEMA);

    // find all defines
    DefineFinder deff = new DefineFinder();
    grammar.accept(deff);
    this.defs = deff.defs;

    if(opts.defaultPackage2!=null)
        pkg = codeModel._package(opts.defaultPackage2);
    else
    if(opts.defaultPackage!=null)
        pkg = codeModel._package(opts.defaultPackage);
    else
        pkg = codeModel.rootPackage();
}
 
Example #7
Source File: CompatibilityDatatypeLibrary.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
public DatatypeBuilder createDatatypeBuilder(String type)
    throws DatatypeException {
    if (type.equals("ID")
        || type.equals("IDREF")
        || type.equals("IDREFS")) {
        if (xsdDatatypeLibrary == null) {
            xsdDatatypeLibrary =
                factory.createDatatypeLibrary(
                    WellKnownNamespaces.XML_SCHEMA_DATATYPES);
            if (xsdDatatypeLibrary == null)
                throw new DatatypeException();
        }
        return xsdDatatypeLibrary.createDatatypeBuilder(type);
    }
    throw new DatatypeException();
}
 
Example #8
Source File: DXMLPrinter.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
public Void onGrammar(DGrammarPattern p) {
    start("grammar");
    ns(null, WellKnownNamespaces.RELAX_NG);
    on(p.getAnnotation());
    start("start");
    on(p.getStart());
    end();
    for (DDefine d : p) {
        start("define");
        attr("name", d.getName());
        on(d.getAnnotation());
        unwrapGroup(d.getPattern());
        end();
    }
    end();
    return null;
}
 
Example #9
Source File: RELAXNGCompiler.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
public RELAXNGCompiler(DPattern grammar, JCodeModel codeModel, Options opts) {
    this.grammar = grammar;
    this.opts = opts;
    this.model = new Model(opts,codeModel, NameConverter.smart,opts.classNameAllocator,null);

    datatypes.put("",DatatypeLib.BUILTIN);
    datatypes.put(WellKnownNamespaces.XML_SCHEMA_DATATYPES,DatatypeLib.XMLSCHEMA);

    // find all defines
    DefineFinder deff = new DefineFinder();
    grammar.accept(deff);
    this.defs = deff.defs;

    if(opts.defaultPackage2!=null)
        pkg = codeModel._package(opts.defaultPackage2);
    else
    if(opts.defaultPackage!=null)
        pkg = codeModel._package(opts.defaultPackage);
    else
        pkg = codeModel.rootPackage();
}
 
Example #10
Source File: RELAXNGCompiler.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
public RELAXNGCompiler(DPattern grammar, JCodeModel codeModel, Options opts) {
    this.grammar = grammar;
    this.opts = opts;
    this.model = new Model(opts,codeModel, NameConverter.smart,opts.classNameAllocator,null);

    datatypes.put("",DatatypeLib.BUILTIN);
    datatypes.put(WellKnownNamespaces.XML_SCHEMA_DATATYPES,DatatypeLib.XMLSCHEMA);

    // find all defines
    DefineFinder deff = new DefineFinder();
    grammar.accept(deff);
    this.defs = deff.defs;

    if(opts.defaultPackage2!=null)
        pkg = codeModel._package(opts.defaultPackage2);
    else
    if(opts.defaultPackage!=null)
        pkg = codeModel._package(opts.defaultPackage);
    else
        pkg = codeModel.rootPackage();
}
 
Example #11
Source File: RELAXNGCompiler.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
public RELAXNGCompiler(DPattern grammar, JCodeModel codeModel, Options opts) {
    this.grammar = grammar;
    this.opts = opts;
    this.model = new Model(opts,codeModel, NameConverter.smart,opts.classNameAllocator,null);

    datatypes.put("",DatatypeLib.BUILTIN);
    datatypes.put(WellKnownNamespaces.XML_SCHEMA_DATATYPES,DatatypeLib.XMLSCHEMA);

    // find all defines
    DefineFinder deff = new DefineFinder();
    grammar.accept(deff);
    this.defs = deff.defs;

    if(opts.defaultPackage2!=null)
        pkg = codeModel._package(opts.defaultPackage2);
    else
    if(opts.defaultPackage!=null)
        pkg = codeModel._package(opts.defaultPackage);
    else
        pkg = codeModel.rootPackage();
}
 
Example #12
Source File: CompatibilityDatatypeLibrary.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
public DatatypeBuilder createDatatypeBuilder(String type)
    throws DatatypeException {
    if (type.equals("ID")
        || type.equals("IDREF")
        || type.equals("IDREFS")) {
        if (xsdDatatypeLibrary == null) {
            xsdDatatypeLibrary =
                factory.createDatatypeLibrary(
                    WellKnownNamespaces.XML_SCHEMA_DATATYPES);
            if (xsdDatatypeLibrary == null)
                throw new DatatypeException();
        }
        return xsdDatatypeLibrary.createDatatypeBuilder(type);
    }
    throw new DatatypeException();
}
 
Example #13
Source File: DXMLPrinter.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
public Void onGrammar(DGrammarPattern p) {
    start("grammar");
    ns(null, WellKnownNamespaces.RELAX_NG);
    on(p.getAnnotation());
    start("start");
    on(p.getStart());
    end();
    for (DDefine d : p) {
        start("define");
        attr("name", d.getName());
        on(d.getAnnotation());
        unwrapGroup(d.getPattern());
        end();
    }
    end();
    return null;
}
 
Example #14
Source File: DXMLPrinter.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
public Void onGrammar(DGrammarPattern p) {
    start("grammar");
    ns(null, WellKnownNamespaces.RELAX_NG);
    on(p.getAnnotation());
    start("start");
    on(p.getStart());
    end();
    for (DDefine d : p) {
        start("define");
        attr("name", d.getName());
        on(d.getAnnotation());
        unwrapGroup(d.getPattern());
        end();
    }
    end();
    return null;
}
 
Example #15
Source File: DXMLPrinter.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
public Void onGrammar(DGrammarPattern p) {
    start("grammar");
    ns(null, WellKnownNamespaces.RELAX_NG);
    on(p.getAnnotation());
    start("start");
    on(p.getStart());
    end();
    for (DDefine d : p) {
        start("define");
        attr("name", d.getName());
        on(d.getAnnotation());
        unwrapGroup(d.getPattern());
        end();
    }
    end();
    return null;
}
 
Example #16
Source File: CompactSyntax.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
final public ParsedElementAnnotation Documentation() throws ParseException {
CommentList comments = getComments();
ElementAnnotationBuilder eab;
Token t;
  switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  case DOCUMENTATION:
    t = jj_consume_token(DOCUMENTATION);
    break;
  case DOCUMENTATION_AFTER_SINGLE_LINE_COMMENT:
    t = jj_consume_token(DOCUMENTATION_AFTER_SINGLE_LINE_COMMENT);
    break;
  default:
    jj_la1[54] = jj_gen;
    jj_consume_token(-1);
    throw new ParseException();
  }
  eab = sb.makeElementAnnotationBuilder(WellKnownNamespaces.RELAX_NG_COMPATIBILITY_ANNOTATIONS,
                                        "documentation",
                                        getCompatibilityPrefix(),
                                        makeLocation(t),
                                        comments,
                                        getContext());
  eab.addText(mungeComment(t.image), makeLocation(t), null);
  label_19:
  while (true) {
    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
    case DOCUMENTATION_CONTINUE:
      ;
      break;
    default:
      jj_la1[55] = jj_gen;
      break label_19;
    }
    t = jj_consume_token(DOCUMENTATION_CONTINUE);
                                eab.addText("\u005cn" + mungeComment(t.image), makeLocation(t), null);
  }
  {if (true) return eab.makeElementAnnotation();}
  throw new Error("Missing return statement in function");
}
 
Example #17
Source File: SchemaParser.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
@Override
boolean isRelaxNGElement(String uri) throws SAXException {
    if (!uri.startsWith(relaxngURIPrefix)) {
        return false;
    }
    if (!uri.equals(WellKnownNamespaces.RELAX_NG)) {
        warning("wrong_uri_version",
                WellKnownNamespaces.RELAX_NG.substring(relaxngURIPrefix.length()),
                uri.substring(relaxngURIPrefix.length()));
    }
    relaxngURI = uri;
    return true;
}
 
Example #18
Source File: BuiltinDatatypeLibrary.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public DatatypeBuilder createDatatypeBuilder(String type)
    throws DatatypeException {
    xsdDatatypeLibrary =
        factory.createDatatypeLibrary(
            WellKnownNamespaces.XML_SCHEMA_DATATYPES);
    if (xsdDatatypeLibrary == null)
        throw new DatatypeException();

    if (type.equals("string") || type.equals("token")) {
        return new BuiltinDatatypeBuilder(
            xsdDatatypeLibrary.createDatatype(type));
    }
    throw new DatatypeException();
}
 
Example #19
Source File: SchemaParser.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
void attributes(Attributes atts) throws SAXException {
    int len = atts.getLength();
    for (int i = 0; i < len; i++) {
        String uri = atts.getURI(i);
        if (uri.length() == 0) {
            String name = atts.getLocalName(i);
            if (name.equals("name")) {
                setName(atts.getValue(i).trim());
            } else if (name.equals("ns")) {
                ns = atts.getValue(i);
            } else if (name.equals("datatypeLibrary")) {
                datatypeLibrary = atts.getValue(i);
                checkUri(datatypeLibrary);
                if (!datatypeLibrary.equals("")
                        && !Uri.isAbsolute(datatypeLibrary)) {
                    error("relative_datatype_library");
                }
                if (Uri.hasFragmentId(datatypeLibrary)) {
                    error("fragment_identifier_datatype_library");
                }
                datatypeLibrary = Uri.escapeDisallowedChars(datatypeLibrary);
            } else {
                setOtherAttribute(name, atts.getValue(i));
            }
        } else if (uri.equals(relaxngURI)) {
            error("qualified_attribute", atts.getLocalName(i));
        } else if (uri.equals(WellKnownNamespaces.XML)
                && atts.getLocalName(i).equals("base")) {
            xmlBaseHandler.xmlBaseAttribute(atts.getValue(i));
        } else {
            if (annotations == null) {
                annotations = schemaBuilder.makeAnnotations(null, getContext());
            }
            annotations.addAttribute(uri, atts.getLocalName(i), findPrefix(atts.getQName(i), uri),
                    atts.getValue(i), startLocation);
        }
    }
    endAttributes();
}
 
Example #20
Source File: CompactSyntax.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
final public ParsedElementAnnotation PrefixedAnnotationElement(boolean nested) throws ParseException {
CommentList comments = getComments();
Token t;
ElementAnnotationBuilder eab;
  t = jj_consume_token(PREFIXED_NAME);
  String qn = t.image;
  int colon = qn.indexOf(':');
  String prefix = qn.substring(0, colon);
  String ns = lookupPrefix(prefix, t);
  if (ns == this.inheritedNs) {
    error("inherited_annotation_namespace", t);
    ns = "";
  }
  else if (!nested && ns.equals(WellKnownNamespaces.RELAX_NG)) {
    error("relax_ng_namespace", t);
    ns = "";
  }
  else {
    if (ns.length() == 0)
      prefix = null;
  }
  eab = sb.makeElementAnnotationBuilder(ns, qn.substring(colon + 1), prefix,
                                        makeLocation(t), comments, getContext());
  AnnotationElementContent(eab);
  {if (true) return eab.makeElementAnnotation();}
  throw new Error("Missing return statement in function");
}
 
Example #21
Source File: CompactSyntax.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
final public ParsedElementAnnotation Documentation() throws ParseException {
CommentList comments = getComments();
ElementAnnotationBuilder eab;
Token t;
  switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  case DOCUMENTATION:
    t = jj_consume_token(DOCUMENTATION);
    break;
  case DOCUMENTATION_AFTER_SINGLE_LINE_COMMENT:
    t = jj_consume_token(DOCUMENTATION_AFTER_SINGLE_LINE_COMMENT);
    break;
  default:
    jj_la1[54] = jj_gen;
    jj_consume_token(-1);
    throw new ParseException();
  }
  eab = sb.makeElementAnnotationBuilder(WellKnownNamespaces.RELAX_NG_COMPATIBILITY_ANNOTATIONS,
                                        "documentation",
                                        getCompatibilityPrefix(),
                                        makeLocation(t),
                                        comments,
                                        getContext());
  eab.addText(mungeComment(t.image), makeLocation(t), null);
  label_19:
  while (true) {
    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
    case DOCUMENTATION_CONTINUE:
      ;
      break;
    default:
      jj_la1[55] = jj_gen;
      break label_19;
    }
    t = jj_consume_token(DOCUMENTATION_CONTINUE);
                                eab.addText("\u005cn" + mungeComment(t.image), makeLocation(t), null);
  }
  {if (true) return eab.makeElementAnnotation();}
  throw new Error("Missing return statement in function");
}
 
Example #22
Source File: CompactSyntax.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
final public void PrefixedAnnotationAttribute(Annotations a, boolean nested) throws ParseException {
Token t;
String value;
  t = jj_consume_token(PREFIXED_NAME);
  jj_consume_token(2);
  value = Literal();
  String qn = t.image;
  int colon = qn.indexOf(':');
  String prefix = qn.substring(0, colon);
  String ns = lookupPrefix(prefix, t);
  if (ns == this.inheritedNs)
    error("inherited_annotation_namespace", t);
  else if (ns.length() == 0 && !nested)
    error("unqualified_annotation_attribute", t);
  else if (ns.equals(WellKnownNamespaces.RELAX_NG) && !nested)
    error("relax_ng_namespace", t);
  /*else if (ns.length() == 0
           && qn.length() - colon - 1 == 5
           && qn.regionMatches(colon + 1, "xmlns", 0, 5))
    error("xmlns_annotation_attribute", t);*/
  else if (ns.equals(WellKnownNamespaces.XMLNS))
    error("xmlns_annotation_attribute_uri", t);
  else {
    if (ns.length() == 0)
      prefix = null;
    addAttribute(a, ns, qn.substring(colon + 1), prefix, value, t);
  }
}
 
Example #23
Source File: CompactSyntax.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
final public ParsedElementAnnotation Documentation() throws ParseException {
CommentList comments = getComments();
ElementAnnotationBuilder eab;
Token t;
  switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
  case DOCUMENTATION:
    t = jj_consume_token(DOCUMENTATION);
    break;
  case DOCUMENTATION_AFTER_SINGLE_LINE_COMMENT:
    t = jj_consume_token(DOCUMENTATION_AFTER_SINGLE_LINE_COMMENT);
    break;
  default:
    jj_la1[54] = jj_gen;
    jj_consume_token(-1);
    throw new ParseException();
  }
  eab = sb.makeElementAnnotationBuilder(WellKnownNamespaces.RELAX_NG_COMPATIBILITY_ANNOTATIONS,
                                        "documentation",
                                        getCompatibilityPrefix(),
                                        makeLocation(t),
                                        comments,
                                        getContext());
  eab.addText(mungeComment(t.image), makeLocation(t), null);
  label_19:
  while (true) {
    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
    case DOCUMENTATION_CONTINUE:
      ;
      break;
    default:
      jj_la1[55] = jj_gen;
      break label_19;
    }
    t = jj_consume_token(DOCUMENTATION_CONTINUE);
                                eab.addText("\u005cn" + mungeComment(t.image), makeLocation(t), null);
  }
  {if (true) return eab.makeElementAnnotation();}
  throw new Error("Missing return statement in function");
}
 
Example #24
Source File: SchemaParser.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
void attributes(Attributes atts) throws SAXException {
    int len = atts.getLength();
    for (int i = 0; i < len; i++) {
        String uri = atts.getURI(i);
        if (uri.length() == 0) {
            String name = atts.getLocalName(i);
            if (name.equals("name")) {
                setName(atts.getValue(i).trim());
            } else if (name.equals("ns")) {
                ns = atts.getValue(i);
            } else if (name.equals("datatypeLibrary")) {
                datatypeLibrary = atts.getValue(i);
                checkUri(datatypeLibrary);
                if (!datatypeLibrary.equals("")
                        && !Uri.isAbsolute(datatypeLibrary)) {
                    error("relative_datatype_library");
                }
                if (Uri.hasFragmentId(datatypeLibrary)) {
                    error("fragment_identifier_datatype_library");
                }
                datatypeLibrary = Uri.escapeDisallowedChars(datatypeLibrary);
            } else {
                setOtherAttribute(name, atts.getValue(i));
            }
        } else if (uri.equals(relaxngURI)) {
            error("qualified_attribute", atts.getLocalName(i));
        } else if (uri.equals(WellKnownNamespaces.XML)
                && atts.getLocalName(i).equals("base")) {
            xmlBaseHandler.xmlBaseAttribute(atts.getValue(i));
        } else {
            if (annotations == null) {
                annotations = schemaBuilder.makeAnnotations(null, getContext());
            }
            annotations.addAttribute(uri, atts.getLocalName(i), findPrefix(atts.getQName(i), uri),
                    atts.getValue(i), startLocation);
        }
    }
    endAttributes();
}
 
Example #25
Source File: CompactSyntax.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
final public void PrefixedAnnotationAttribute(Annotations a, boolean nested) throws ParseException {
Token t;
String value;
  t = jj_consume_token(PREFIXED_NAME);
  jj_consume_token(2);
  value = Literal();
  String qn = t.image;
  int colon = qn.indexOf(':');
  String prefix = qn.substring(0, colon);
  String ns = lookupPrefix(prefix, t);
  if (ns == this.inheritedNs)
    error("inherited_annotation_namespace", t);
  else if (ns.length() == 0 && !nested)
    error("unqualified_annotation_attribute", t);
  else if (ns.equals(WellKnownNamespaces.RELAX_NG) && !nested)
    error("relax_ng_namespace", t);
  /*else if (ns.length() == 0
           && qn.length() - colon - 1 == 5
           && qn.regionMatches(colon + 1, "xmlns", 0, 5))
    error("xmlns_annotation_attribute", t);*/
  else if (ns.equals(WellKnownNamespaces.XMLNS))
    error("xmlns_annotation_attribute_uri", t);
  else {
    if (ns.length() == 0)
      prefix = null;
    addAttribute(a, ns, qn.substring(colon + 1), prefix, value, t);
  }
}
 
Example #26
Source File: CompactSyntax.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
final public ParsedElementAnnotation PrefixedAnnotationElement(boolean nested) throws ParseException {
CommentList comments = getComments();
Token t;
ElementAnnotationBuilder eab;
  t = jj_consume_token(PREFIXED_NAME);
  String qn = t.image;
  int colon = qn.indexOf(':');
  String prefix = qn.substring(0, colon);
  String ns = lookupPrefix(prefix, t);
  if (ns == this.inheritedNs) {
    error("inherited_annotation_namespace", t);
    ns = "";
  }
  else if (!nested && ns.equals(WellKnownNamespaces.RELAX_NG)) {
    error("relax_ng_namespace", t);
    ns = "";
  }
  else {
    if (ns.length() == 0)
      prefix = null;
  }
  eab = sb.makeElementAnnotationBuilder(ns, qn.substring(colon + 1), prefix,
                                        makeLocation(t), comments, getContext());
  AnnotationElementContent(eab);
  {if (true) return eab.makeElementAnnotation();}
  throw new Error("Missing return statement in function");
}
 
Example #27
Source File: BuiltinDatatypeLibrary.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public DatatypeBuilder createDatatypeBuilder(String type)
    throws DatatypeException {
    xsdDatatypeLibrary =
        factory.createDatatypeLibrary(
            WellKnownNamespaces.XML_SCHEMA_DATATYPES);
    if (xsdDatatypeLibrary == null)
        throw new DatatypeException();

    if (type.equals("string") || type.equals("token")) {
        return new BuiltinDatatypeBuilder(
            xsdDatatypeLibrary.createDatatype(type));
    }
    throw new DatatypeException();
}
 
Example #28
Source File: SchemaParser.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
void attributes(Attributes atts) throws SAXException {
    int len = atts.getLength();
    for (int i = 0; i < len; i++) {
        String uri = atts.getURI(i);
        if (uri.length() == 0) {
            String name = atts.getLocalName(i);
            if (name.equals("name")) {
                setName(atts.getValue(i).trim());
            } else if (name.equals("ns")) {
                ns = atts.getValue(i);
            } else if (name.equals("datatypeLibrary")) {
                datatypeLibrary = atts.getValue(i);
                checkUri(datatypeLibrary);
                if (!datatypeLibrary.equals("")
                        && !Uri.isAbsolute(datatypeLibrary)) {
                    error("relative_datatype_library");
                }
                if (Uri.hasFragmentId(datatypeLibrary)) {
                    error("fragment_identifier_datatype_library");
                }
                datatypeLibrary = Uri.escapeDisallowedChars(datatypeLibrary);
            } else {
                setOtherAttribute(name, atts.getValue(i));
            }
        } else if (uri.equals(relaxngURI)) {
            error("qualified_attribute", atts.getLocalName(i));
        } else if (uri.equals(WellKnownNamespaces.XML)
                && atts.getLocalName(i).equals("base")) {
            xmlBaseHandler.xmlBaseAttribute(atts.getValue(i));
        } else {
            if (annotations == null) {
                annotations = schemaBuilder.makeAnnotations(null, getContext());
            }
            annotations.addAttribute(uri, atts.getLocalName(i), findPrefix(atts.getQName(i), uri),
                    atts.getValue(i), startLocation);
        }
    }
    endAttributes();
}
 
Example #29
Source File: CompactSyntax.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
final public void PrefixedAnnotationAttribute(Annotations a, boolean nested) throws ParseException {
Token t;
String value;
  t = jj_consume_token(PREFIXED_NAME);
  jj_consume_token(2);
  value = Literal();
  String qn = t.image;
  int colon = qn.indexOf(':');
  String prefix = qn.substring(0, colon);
  String ns = lookupPrefix(prefix, t);
  if (ns == this.inheritedNs)
    error("inherited_annotation_namespace", t);
  else if (ns.length() == 0 && !nested)
    error("unqualified_annotation_attribute", t);
  else if (ns.equals(WellKnownNamespaces.RELAX_NG) && !nested)
    error("relax_ng_namespace", t);
  /*else if (ns.length() == 0
           && qn.length() - colon - 1 == 5
           && qn.regionMatches(colon + 1, "xmlns", 0, 5))
    error("xmlns_annotation_attribute", t);*/
  else if (ns.equals(WellKnownNamespaces.XMLNS))
    error("xmlns_annotation_attribute_uri", t);
  else {
    if (ns.length() == 0)
      prefix = null;
    addAttribute(a, ns, qn.substring(colon + 1), prefix, value, t);
  }
}
 
Example #30
Source File: CompactSyntax.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
final public ParsedElementAnnotation PrefixedAnnotationElement(boolean nested) throws ParseException {
CommentList comments = getComments();
Token t;
ElementAnnotationBuilder eab;
  t = jj_consume_token(PREFIXED_NAME);
  String qn = t.image;
  int colon = qn.indexOf(':');
  String prefix = qn.substring(0, colon);
  String ns = lookupPrefix(prefix, t);
  if (ns == this.inheritedNs) {
    error("inherited_annotation_namespace", t);
    ns = "";
  }
  else if (!nested && ns.equals(WellKnownNamespaces.RELAX_NG)) {
    error("relax_ng_namespace", t);
    ns = "";
  }
  else {
    if (ns.length() == 0)
      prefix = null;
  }
  eab = sb.makeElementAnnotationBuilder(ns, qn.substring(colon + 1), prefix,
                                        makeLocation(t), comments, getContext());
  AnnotationElementContent(eab);
  {if (true) return eab.makeElementAnnotation();}
  throw new Error("Missing return statement in function");
}