com.sun.org.apache.xerces.internal.impl.xs.SchemaGrammar Java Examples
The following examples show how to use
com.sun.org.apache.xerces.internal.impl.xs.SchemaGrammar.
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: XSDHandler.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
/** * Namespace growth * * Go throuth the grammar bucket, and for each grammar in the bucket * check the import list. If there exists a grammar in import list * that has the same namespace as newGrammar, but a different instance, * then update the import list and replace the old grammar instance with * the new one */ private void updateImportListWith(SchemaGrammar newGrammar) { SchemaGrammar[] schemaGrammars = fGrammarBucket.getGrammars(); for (int i = 0; i < schemaGrammars.length; ++i) { SchemaGrammar sg = schemaGrammars[i]; if (sg != newGrammar) { Vector importedGrammars = sg.getImportedGrammars(); if (importedGrammars != null) { for (int j=0; j<importedGrammars.size(); j++) { SchemaGrammar isg = (SchemaGrammar) importedGrammars.elementAt(j); if (null2EmptyString(isg.getTargetNamespace()).equals(null2EmptyString(newGrammar.getTargetNamespace()))) { if (isg != newGrammar) { importedGrammars.set(j, newGrammar); } break; } } } } } }
Example #2
Source File: XSDSimpleTypeTraverser.java From Bytecoder with Apache License 2.0 | 6 votes |
private XSSimpleType errorType(String name, String namespace, short refType) { XSSimpleType stringType = (XSSimpleType)SchemaGrammar.SG_SchemaNS.getTypeDefinition("string"); switch (refType) { case XSConstants.DERIVATION_RESTRICTION: return fSchemaHandler.fDVFactory.createTypeRestriction(name, namespace, (short)0, stringType, null); case XSConstants.DERIVATION_LIST: return fSchemaHandler.fDVFactory.createTypeList(name, namespace, (short)0, stringType, null); case XSConstants.DERIVATION_UNION: return fSchemaHandler.fDVFactory.createTypeUnion(name, namespace, (short)0, new XSSimpleType[]{stringType}, null); } return null; }
Example #3
Source File: XSDHandler.java From hottub with GNU General Public License v2.0 | 6 votes |
private void updateImportList(SchemaGrammar sg, Vector importedGrammars, Vector namespaceList) { final int size = namespaceList.size(); SchemaGrammar isg; for (int i=0; i<size; i++) { isg = fGrammarBucket.getGrammar((String)namespaceList.elementAt(i)); if (isg != null) { if (!containedImportedGrammar(importedGrammars, isg)) { importedGrammars.add(isg); } } else { //REVIST: report an error message } } }
Example #4
Source File: XSDHandler.java From hottub with GNU General Public License v2.0 | 6 votes |
private boolean existingGrammars(Vector grammars) { int length = grammars.size(); final XSDDescription desc = new XSDDescription(); for (int i=0; i < length; i++) { final SchemaGrammar sg1 = (SchemaGrammar)grammars.elementAt(i); desc.setNamespace(sg1.getTargetNamespace()); final SchemaGrammar sg2 = findGrammar(desc, false); if (sg2 != null) { return true; } } return false; }
Example #5
Source File: XSDHandler.java From jdk1.8-source-analysis with Apache License 2.0 | 6 votes |
private boolean existingGrammars(Vector grammars) { int length = grammars.size(); final XSDDescription desc = new XSDDescription(); for (int i=0; i < length; i++) { final SchemaGrammar sg1 = (SchemaGrammar)grammars.elementAt(i); desc.setNamespace(sg1.getTargetNamespace()); final SchemaGrammar sg2 = findGrammar(desc, false); if (sg2 != null) { return true; } } return false; }
Example #6
Source File: XSDSimpleTypeTraverser.java From hottub with GNU General Public License v2.0 | 6 votes |
private XSSimpleType errorType(String name, String namespace, short refType) { XSSimpleType stringType = (XSSimpleType)SchemaGrammar.SG_SchemaNS.getTypeDefinition("string"); switch (refType) { case XSConstants.DERIVATION_RESTRICTION: return fSchemaHandler.fDVFactory.createTypeRestriction(name, namespace, (short)0, stringType, null); case XSConstants.DERIVATION_LIST: return fSchemaHandler.fDVFactory.createTypeList(name, namespace, (short)0, stringType, null); case XSConstants.DERIVATION_UNION: return fSchemaHandler.fDVFactory.createTypeUnion(name, namespace, (short)0, new XSSimpleType[]{stringType}, null); } return null; }
Example #7
Source File: XSGrammarPool.java From Bytecoder with Apache License 2.0 | 6 votes |
public XSModel toXSModel(short schemaVersion) { List<Grammar> list = new ArrayList<>(); for (int i = 0; i < fGrammars.length; i++) { for (Entry entry = fGrammars[i] ; entry != null ; entry = entry.next) { if (entry.desc.getGrammarType().equals(XMLGrammarDescription.XML_SCHEMA)) { list.add(entry.grammar); } } } int size = list.size(); if (size == 0) { return toXSModel(new SchemaGrammar[0], schemaVersion); } SchemaGrammar[] gs = list.toArray(new SchemaGrammar[size]); return toXSModel(gs, schemaVersion); }
Example #8
Source File: XSDHandler.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
private boolean isExistingGrammar(XSDDescription desc, boolean ignoreConflict) { SchemaGrammar sg = fGrammarBucket.getGrammar(desc.getTargetNamespace()); if (sg == null) { return findGrammar(desc, ignoreConflict) != null; } else if (sg.isImmutable()) { return true; } else { try { return sg.getDocumentLocations().contains(XMLEntityManager.expandSystemId(desc.getLiteralSystemId(), desc.getBaseSystemId(), false)); } catch (MalformedURIException e) { return false; } } }
Example #9
Source File: XSGrammarPool.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
public XSModel toXSModel(short schemaVersion) { ArrayList list = new ArrayList(); for (int i = 0; i < fGrammars.length; i++) { for (Entry entry = fGrammars[i] ; entry != null ; entry = entry.next) { if (entry.desc.getGrammarType().equals(XMLGrammarDescription.XML_SCHEMA)) { list.add(entry.grammar); } } } int size = list.size(); if (size == 0) { return toXSModel(new SchemaGrammar[0], schemaVersion); } SchemaGrammar[] gs = (SchemaGrammar[])list.toArray(new SchemaGrammar[size]); return toXSModel(gs, schemaVersion); }
Example #10
Source File: XSDHandler.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
private void addGrammarComponents(SchemaGrammar srcGrammar, SchemaGrammar dstGrammar) { if (dstGrammar == null) { createGrammarFrom(srcGrammar); return; } SchemaGrammar tmpGrammar = dstGrammar; if (tmpGrammar.isImmutable()) { tmpGrammar = createGrammarFrom(dstGrammar); } // add any new locations addNewGrammarLocations(srcGrammar, tmpGrammar); // add any new imported grammars addNewImportedGrammars(srcGrammar, tmpGrammar); // add any new global components addNewGrammarComponents(srcGrammar, tmpGrammar); }
Example #11
Source File: XSDComplexTypeTraverser.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
private void handleComplexTypeError(String messageId,Object[] args, Element e) { if (messageId!=null) { reportSchemaError(messageId, args, e); } // // Mock up the typeInfo structure so that there won't be problems during // validation // fBaseType = SchemaGrammar.fAnyType; fContentType = XSComplexTypeDecl.CONTENTTYPE_MIXED; fXSSimpleType = null; fParticle = getErrorContent(); // REVISIT: do we need to remove all attribute uses already added into // the attribute group? maybe it's ok to leave them there. -SG fAttrGrp.fAttributeWC = getErrorWildcard(); return; }
Example #12
Source File: XSDComplexTypeTraverser.java From Bytecoder with Apache License 2.0 | 6 votes |
private void handleComplexTypeError(String messageId,Object[] args, Element e) { if (messageId!=null) { reportSchemaError(messageId, args, e); } // // Mock up the typeInfo structure so that there won't be problems during // validation // fBaseType = SchemaGrammar.fAnyType; fContentType = XSComplexTypeDecl.CONTENTTYPE_MIXED; fXSSimpleType = null; fParticle = getErrorContent(); // REVISIT: do we need to remove all attribute uses already added into // the attribute group? maybe it's ok to leave them there. -SG fAttrGrp.fAttributeWC = getErrorWildcard(); }
Example #13
Source File: XSDHandler.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
private void addGrammarComponents(SchemaGrammar srcGrammar, SchemaGrammar dstGrammar) { if (dstGrammar == null) { createGrammarFrom(srcGrammar); return; } SchemaGrammar tmpGrammar = dstGrammar; if (tmpGrammar.isImmutable()) { tmpGrammar = createGrammarFrom(dstGrammar); } // add any new locations addNewGrammarLocations(srcGrammar, tmpGrammar); // add any new imported grammars addNewImportedGrammars(srcGrammar, tmpGrammar); // add any new global components addNewGrammarComponents(srcGrammar, tmpGrammar); }
Example #14
Source File: XSDHandler.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
private boolean isExistingGrammar(XSDDescription desc, boolean ignoreConflict) { SchemaGrammar sg = fGrammarBucket.getGrammar(desc.getTargetNamespace()); if (sg == null) { return findGrammar(desc, ignoreConflict) != null; } else if (sg.isImmutable()) { return true; } else { try { return sg.getDocumentLocations().contains(XMLEntityManager.expandSystemId(desc.getLiteralSystemId(), desc.getBaseSystemId(), false)); } catch (MalformedURIException e) { return false; } } }
Example #15
Source File: XSDComplexTypeTraverser.java From jdk1.8-source-analysis with Apache License 2.0 | 6 votes |
/** * Traverse local complexType declarations * * @param Element * @param XSDocumentInfo * @param SchemaGrammar * @return XSComplexTypeDecl */ XSComplexTypeDecl traverseLocal(Element complexTypeNode, XSDocumentInfo schemaDoc, SchemaGrammar grammar) { Object[] attrValues = fAttrChecker.checkAttributes(complexTypeNode, false, schemaDoc); String complexTypeName = genAnonTypeName(complexTypeNode); contentBackup(); XSComplexTypeDecl type = traverseComplexTypeDecl (complexTypeNode, complexTypeName, attrValues, schemaDoc, grammar); contentRestore(); // need to add the type to the grammar for later constraint checking grammar.addComplexTypeDecl(type, fSchemaHandler.element2Locator(complexTypeNode)); type.setIsAnonymous(); fAttrChecker.returnAttrArray(attrValues, schemaDoc); return type; }
Example #16
Source File: XSDComplexTypeTraverser.java From jdk1.8-source-analysis with Apache License 2.0 | 6 votes |
private void handleComplexTypeError(String messageId,Object[] args, Element e) { if (messageId!=null) { reportSchemaError(messageId, args, e); } // // Mock up the typeInfo structure so that there won't be problems during // validation // fBaseType = SchemaGrammar.fAnyType; fContentType = XSComplexTypeDecl.CONTENTTYPE_MIXED; fXSSimpleType = null; fParticle = getErrorContent(); // REVISIT: do we need to remove all attribute uses already added into // the attribute group? maybe it's ok to leave them there. -SG fAttrGrp.fAttributeWC = getErrorWildcard(); return; }
Example #17
Source File: XSDHandler.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
protected Object getGlobalDeclFromGrammar(SchemaGrammar sGrammar, int declType, String localpart) { Object retObj = null; switch (declType) { case ATTRIBUTE_TYPE : retObj = sGrammar.getGlobalAttributeDecl(localpart); break; case ATTRIBUTEGROUP_TYPE : retObj = sGrammar.getGlobalAttributeGroupDecl(localpart); break; case ELEMENT_TYPE : retObj = sGrammar.getGlobalElementDecl(localpart); break; case GROUP_TYPE : retObj = sGrammar.getGlobalGroupDecl(localpart); break; case IDENTITYCONSTRAINT_TYPE : retObj = sGrammar.getIDConstraintDecl(localpart); break; case NOTATION_TYPE : retObj = sGrammar.getGlobalNotationDecl(localpart); break; case TYPEDECL_TYPE : retObj = sGrammar.getGlobalTypeDecl(localpart); break; } return retObj; }
Example #18
Source File: XSDHandler.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
private void addGrammars(Vector grammars) { int length = grammars.size(); XSDDescription desc = new XSDDescription(); for (int i=0; i < length; i++) { final SchemaGrammar sg1 = (SchemaGrammar)grammars.elementAt(i); desc.setNamespace(sg1.getTargetNamespace()); final SchemaGrammar sg2 = findGrammar(desc, fNamespaceGrowth); if (sg1 != sg2) { addGrammarComponents(sg1, sg2); } } }
Example #19
Source File: XSDHandler.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
/** * Namespace growth * * Go through the import list of a given grammar and for each imported * grammar, check to see if the grammar bucket has a newer version. * If a new instance is found, we update the import list with the * newer version. */ private void updateImportListFor(SchemaGrammar grammar) { Vector importedGrammars = grammar.getImportedGrammars(); if (importedGrammars != null) { for (int i=0; i<importedGrammars.size(); i++) { SchemaGrammar isg1 = (SchemaGrammar) importedGrammars.elementAt(i); SchemaGrammar isg2 = fGrammarBucket.getGrammar(isg1.getTargetNamespace()); if (isg2 != null && isg1 != isg2) { importedGrammars.set(i, isg2); } } } }
Example #20
Source File: XSDHandler.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
private void addNewGrammarLocations(SchemaGrammar srcGrammar, SchemaGrammar dstGrammar) { final StringList locations = srcGrammar.getDocumentLocations(); final int locSize = locations.size(); final StringList locations2 = dstGrammar.getDocumentLocations(); for (int i=0; i<locSize; i++) { String loc = locations.item(i); if (!locations2.contains(loc)) { dstGrammar.addDocument(null, loc); } } }
Example #21
Source File: XSDSimpleTypeTraverser.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
XSSimpleType traverseLocal(Element elmNode, XSDocumentInfo schemaDoc, SchemaGrammar grammar) { // General Attribute Checking Object[] attrValues = fAttrChecker.checkAttributes(elmNode, false, schemaDoc); String name = genAnonTypeName(elmNode); XSSimpleType type = getSimpleType (name, elmNode, attrValues, schemaDoc, grammar); if (type instanceof XSSimpleTypeDecl) { ((XSSimpleTypeDecl)type).setAnonymous(true); } fAttrChecker.returnAttrArray(attrValues, schemaDoc); return type; }
Example #22
Source File: XSDHandler.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
protected void resolveKeyRefs() { for (int i=0; i<fKeyrefStackPos; i++) { XSDocumentInfo keyrefSchemaDoc = fKeyrefsMapXSDocumentInfo[i]; keyrefSchemaDoc.fNamespaceSupport.makeGlobal(); keyrefSchemaDoc.fNamespaceSupport.setEffectiveContext( fKeyrefNamespaceContext[i] ); SchemaGrammar keyrefGrammar = fGrammarBucket.getGrammar(keyrefSchemaDoc.fTargetNamespace); // need to set <keyref> to hidden before traversing it, // because it has global scope DOMUtil.setHidden(fKeyrefs[i], fHiddenNodes); fKeyrefTraverser.traverse(fKeyrefs[i], fKeyrefElems[i], keyrefSchemaDoc, keyrefGrammar); } }
Example #23
Source File: XMLGrammarCachingConfiguration.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
SchemaGrammar parseXMLSchema(XMLInputSource is) throws IOException { XMLEntityResolver resolver = getEntityResolver(); if(resolver != null) { fSchemaLoader.setEntityResolver(resolver); } if (fErrorReporter.getMessageFormatter(XSMessageFormatter.SCHEMA_DOMAIN) == null) { fErrorReporter.putMessageFormatter(XSMessageFormatter.SCHEMA_DOMAIN, new XSMessageFormatter()); } fSchemaLoader.setProperty(ERROR_REPORTER, fErrorReporter); String propPrefix = Constants.XERCES_PROPERTY_PREFIX; String propName = propPrefix + Constants.SCHEMA_LOCATION; fSchemaLoader.setProperty(propName, getProperty(propName)); propName = propPrefix + Constants.SCHEMA_NONS_LOCATION; fSchemaLoader.setProperty(propName, getProperty(propName)); propName = Constants.JAXP_PROPERTY_PREFIX+Constants.SCHEMA_SOURCE; fSchemaLoader.setProperty(propName, getProperty(propName)); fSchemaLoader.setFeature(SCHEMA_FULL_CHECKING, getFeature(SCHEMA_FULL_CHECKING)); // Should check whether the grammar with this namespace is already in // the grammar resolver. But since we don't know the target namespace // of the document here, we leave such check to XSDHandler SchemaGrammar grammar = (SchemaGrammar)fSchemaLoader.loadGrammar(is); // by default, hand it off to the grammar pool if (grammar != null) { fGrammarPool.cacheGrammars(XMLGrammarDescription.XML_SCHEMA, new Grammar[]{grammar}); } return grammar; }
Example #24
Source File: XSDSimpleTypeTraverser.java From JDKSourceCode1.8 with MIT License | 5 votes |
private XSSimpleType traverseSimpleTypeDecl(Element simpleTypeDecl, Object[] attrValues, XSDocumentInfo schemaDoc, SchemaGrammar grammar) { // get name and final values String name = (String)attrValues[XSAttributeChecker.ATTIDX_NAME]; return getSimpleType(name, simpleTypeDecl, attrValues, schemaDoc, grammar); }
Example #25
Source File: XSDHandler.java From hottub with GNU General Public License v2.0 | 5 votes |
/** * Namespace growth * * Go through the import list of a given grammar and for each imported * grammar, check to see if the grammar bucket has a newer version. * If a new instance is found, we update the import list with the * newer version. */ private void updateImportListFor(SchemaGrammar grammar) { Vector importedGrammars = grammar.getImportedGrammars(); if (importedGrammars != null) { for (int i=0; i<importedGrammars.size(); i++) { SchemaGrammar isg1 = (SchemaGrammar) importedGrammars.elementAt(i); SchemaGrammar isg2 = fGrammarBucket.getGrammar(isg1.getTargetNamespace()); if (isg2 != null && isg1 != isg2) { importedGrammars.set(i, isg2); } } } }
Example #26
Source File: XSDHandler.java From JDKSourceCode1.8 with MIT License | 5 votes |
private void addImportList(SchemaGrammar sg, Vector importedGrammars, Vector namespaceList) { final int size = namespaceList.size(); SchemaGrammar isg; for (int i=0; i<size; i++) { isg = fGrammarBucket.getGrammar((String)namespaceList.elementAt(i)); if (isg != null) { importedGrammars.add(isg); } else { //REVIST: report an error message } } }
Example #27
Source File: XSDHandler.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
public Grammar[] retrieveInitialGrammarSet(String grammarType) { if (grammarType == XMLGrammarDescription.XML_SCHEMA) { if (fInitialGrammarSet == null) { if (fGrammarBucket == null) { fInitialGrammarSet = new Grammar [] {SchemaGrammar.Schema4Annotations.INSTANCE}; } else { SchemaGrammar [] schemaGrammars = fGrammarBucket.getGrammars(); /** * If the grammar bucket already contains the schema for schemas * then we already have the definitions for the parts relevant * to annotations. */ for (int i = 0; i < schemaGrammars.length; ++i) { if (SchemaSymbols.URI_SCHEMAFORSCHEMA.equals(schemaGrammars[i].getTargetNamespace())) { fInitialGrammarSet = schemaGrammars; return fInitialGrammarSet; } } Grammar [] grammars = new Grammar[schemaGrammars.length + 1]; System.arraycopy(schemaGrammars, 0, grammars, 0, schemaGrammars.length); grammars[grammars.length - 1] = SchemaGrammar.Schema4Annotations.INSTANCE; fInitialGrammarSet = grammars; } } return fInitialGrammarSet; } return new Grammar[0]; }
Example #28
Source File: XSDElementTraverser.java From jdk1.8-source-analysis with Apache License 2.0 | 5 votes |
/** * Traverse a globally declared element. * * @param elmDecl * @param schemaDoc * @param grammar * @return the element declaration */ XSElementDecl traverseGlobal(Element elmDecl, XSDocumentInfo schemaDoc, SchemaGrammar grammar) { // General Attribute Checking' Object[] attrValues = fAttrChecker.checkAttributes(elmDecl, true, schemaDoc); XSElementDecl element = traverseNamedElement(elmDecl, attrValues, schemaDoc, grammar, true, null); fAttrChecker.returnAttrArray(attrValues, schemaDoc); return element; }
Example #29
Source File: XSDElementTraverser.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
/** * Traverse a globally declared element. * * @param elmDecl * @param schemaDoc * @param grammar * @return the element declaration */ XSElementDecl traverseGlobal(Element elmDecl, XSDocumentInfo schemaDoc, SchemaGrammar grammar) { // General Attribute Checking' Object[] attrValues = fAttrChecker.checkAttributes(elmDecl, true, schemaDoc); XSElementDecl element = traverseNamedElement(elmDecl, attrValues, schemaDoc, grammar, true, null); fAttrChecker.returnAttrArray(attrValues, schemaDoc); return element; }
Example #30
Source File: XSDSimpleTypeTraverser.java From Bytecoder with Apache License 2.0 | 5 votes |
XSSimpleType traverseLocal(Element elmNode, XSDocumentInfo schemaDoc, SchemaGrammar grammar) { // General Attribute Checking Object[] attrValues = fAttrChecker.checkAttributes(elmNode, false, schemaDoc); String name = genAnonTypeName(elmNode); XSSimpleType type = getSimpleType (name, elmNode, attrValues, schemaDoc, grammar); if (type instanceof XSSimpleTypeDecl) { ((XSSimpleTypeDecl)type).setAnonymous(true); } fAttrChecker.returnAttrArray(attrValues, schemaDoc); return type; }