/** * Pull the grammar out of the bucket simply using * its TNS as a key */ SchemaGrammar getGrammar(String tns) { return fGrammarBucket.getGrammar(tns); }
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 } } }
public XSElementDecl getGlobalElementDecl(QName element) { SchemaGrammar sGrammar = fGrammarBucket.getGrammar(element.uri); if (sGrammar != null) { return sGrammar.getGlobalElementDecl(element.localpart); } return null; }
public XSElementDecl getGlobalElementDecl(QName name) { SchemaGrammar sg = gb.getGrammar(name.uri); return sg != null ? sg.getGlobalElementDecl(name.localpart) : null; }
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 } } }
void checkForDuplicateNames(String qName, int declType, Element currComp) { int namespaceEnd = qName.indexOf(','); String namespace = qName.substring(0, namespaceEnd); SchemaGrammar grammar = fGrammarBucket.getGrammar(emptyString2Null(namespace)); if (grammar != null) { Object obj = getGlobalDeclFromGrammar(grammar, declType, qName.substring(namespaceEnd + 1)); if (obj != null) { reportSchemaError("sch-props-correct.2", new Object []{qName}, currComp); } } }
/** * 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); } } } }
public Grammar retrieveGrammar(XMLGrammarDescription desc) { if (desc.getGrammarType() == XMLGrammarDescription.XML_SCHEMA) { final String tns = ((XMLSchemaDescription) desc).getTargetNamespace(); if (fGrammarBucket != null) { Grammar grammar = fGrammarBucket.getGrammar(tns); if (grammar != null) { return grammar; } } if (SchemaSymbols.URI_SCHEMAFORSCHEMA.equals(tns)) { return SchemaGrammar.Schema4Annotations.getSchema4Annotations(fSchemaVersion); } } return null; }
String attrLocal = attrRName.substring(attrRName.indexOf(',')+1); SchemaGrammar sGrammar = grammarBucket.getGrammar(attrURI); if (sGrammar == null) { continue;
private void expandImportList(String namespace, Vector namespaceList) { SchemaGrammar sg = fGrammarBucket.getGrammar(namespace); // shouldn't be null if (sg != null) { Vector isgs = sg.getImportedGrammars(); if (isgs == null) { isgs = new Vector(); addImportList(sg, isgs, namespaceList); sg.setImportedGrammars(isgs); } else { updateImportList(sg, isgs, namespaceList); } } }
SchemaGrammar sg = getGrammar(grammar.fTargetNamespace); if (sg == null) { putGrammar(grammar); sg2 = getGrammar(sg1.fTargetNamespace); if (sg2 == null) {
private void addNewImportedGrammars(SchemaGrammar srcGrammar, SchemaGrammar dstGrammar) { final Vector src = srcGrammar.getImportedGrammars(); if (src != null) { Vector dst = dstGrammar.getImportedGrammars(); if (dst == null) { dst = new Vector(); dstGrammar.setImportedGrammars(dst); } final int size = src.size(); for (int i=0; i<size; i++) { SchemaGrammar sg = (SchemaGrammar) src.elementAt(i); // Can't use the object from the source import list directly. // It's possible there is already a grammar with the same // namespace in the bucket but a different object. // This can happen if the bucket has grammar A1, and we try // to add B and A2, where A2 imports B. When B is added, we // create a new object B' and store it in the bucket. Then we // try to merge A2 and A1. We can't use B. Need to get B' from // the bucket and store it in A's import list. SchemaGrammar sg1 = fGrammarBucket.getGrammar(sg.getTargetNamespace()); if (sg1 != null) { sg = sg1; } if (!containedImportedGrammar(dst, sg)) { dst.add(sg); } } } }
SchemaGrammar sg = getGrammar(grammar.fTargetNamespace); if (sg != null) { sg2 = getGrammar(sg1.fTargetNamespace); if (sg2 == null) {
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); } } // end resolveKeyRefs
protected void resolveIdentityConstraintReferrals() { for (int i=0; i<fICReferralStackPos; i++) { XSDocumentInfo icReferralSchemaDoc = fICReferralsMapXSDocumentInfo[i]; icReferralSchemaDoc.fNamespaceSupport.makeGlobal(); icReferralSchemaDoc.fNamespaceSupport.setEffectiveContext( fICReferralNamespaceContext[i] ); SchemaGrammar icReferralGrammar = fGrammarBucket.getGrammar(icReferralSchemaDoc.fTargetNamespace); // need to set the identity constraint to hidden before traversing it, // because it has global scope DOMUtil.setHidden(fICReferrals[i], fHiddenNodes); // using the uniqueOrKey traverser to access the method located in abstractIDConstraintTraverser fUniqueOrKeyTraverser.traverseIdentityConstraintReferral(fICReferrals[i], fICReferralElems[i], icReferralSchemaDoc, icReferralGrammar); } } // end resolveIdentityConstraintReferrals
/** * First try to find a grammar in the bucket, if failed, consult the * grammar pool. If a grammar is found in the pool, then add it (and all * imported ones) into the bucket. */ protected SchemaGrammar findGrammar(XSDDescription desc, boolean ignoreConflict) { SchemaGrammar sg = fGrammarBucket.getGrammar(desc.getTargetNamespace()); if (sg == null) { if (fGrammarPool != null) { sg = (SchemaGrammar)fGrammarPool.retrieveGrammar(desc); if (sg != null) { // put this grammar into the bucket, along with grammars // imported by it (directly or indirectly) if (!fGrammarBucket.putGrammar(sg, true, ignoreConflict)) { // REVISIT: a conflict between new grammar(s) and grammars // in the bucket. What to do? A warning? An exception? reportSchemaWarning("GrammarConflict", null, null); sg = null; } } } } return sg; }
final XSWildcardDecl wc = (XSWildcardDecl) wcList.get(i); if (wc.allowName(elem.fTargetNamespace, elem.fName)) { final SchemaGrammar grammar = grammarBucket.getGrammar(elem.fTargetNamespace); if (grammar != null) { final XSElementDecl gElem = grammar.getGlobalElementDecl(elem.fName);
SchemaGrammar currGrammar = fGrammarBucket.getGrammar(currSchema.fTargetNamespace); XSDocumentInfo overridingSchema = getOverridingSchemaDocument(currSchema); if (overridingSchema != null) {
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; } } }
SchemaGrammar grammar = null; grammar = fGrammarBucket.getGrammar(namespace); if (grammar == null) { fXSDDescription.setNamespace(namespace);