📄 xsdabstracttraverser.java
字号:
} if (child != null && DOMUtil.getLocalName(child).equals(SchemaSymbols.ELT_ANNOTATION)) { reportSchemaError("s4s-elt-must-match.1", new Object[]{facet, "(annotation?)", DOMUtil.getLocalName(child)}, child); } } } fAttrChecker.returnAttrArray (attrs, schemaDoc); content = DOMUtil.getNextSiblingElement(content); } if (enumData !=null) { facetsPresent |= XSSimpleType.FACET_ENUMERATION; xsFacets.enumeration = enumData; xsFacets.enumNSDecls = enumNSDecls; xsFacets.enumAnnotations = enumAnnotations; } if (fPattern.length() != 0) { facetsPresent |= XSSimpleType.FACET_PATTERN; xsFacets.pattern = fPattern.toString(); xsFacets.patternAnnotations = patternAnnotations; } fPattern.setLength(0); FacetInfo fi = new FacetInfo(); fi.facetdata = xsFacets; fi.nodeAfterFacets = content; fi.fPresentFacets = facetsPresent; fi.fFixedFacets = facetsFixed; return fi; } // return whether QName/NOTATION is part of the given type private boolean containsQName(XSSimpleType type) { if (type.getVariety() == XSSimpleType.VARIETY_ATOMIC) { short primitive = type.getPrimitiveKind(); return (primitive == XSSimpleType.PRIMITIVE_QNAME || primitive == XSSimpleType.PRIMITIVE_NOTATION); } else if (type.getVariety() == XSSimpleType.VARIETY_LIST) { return containsQName((XSSimpleType)type.getItemType()); } else if (type.getVariety() == XSSimpleType.VARIETY_UNION) { XSObjectList members = type.getMemberTypes(); for (int i = 0; i < members.getLength(); i++) { if (containsQName((XSSimpleType)members.item(i))) return true; } } return false; } // // Traverse a set of attribute and attribute group elements // Needed by complexType and attributeGroup traversal // This method will return the first non-attribute/attrgrp found // Element traverseAttrsAndAttrGrps(Element firstAttr, XSAttributeGroupDecl attrGrp, XSDocumentInfo schemaDoc, SchemaGrammar grammar, XSComplexTypeDecl enclosingCT) { Element child=null; XSAttributeGroupDecl tempAttrGrp = null; XSAttributeUseImpl tempAttrUse = null; String childName; for (child=firstAttr; child!=null; child=DOMUtil.getNextSiblingElement(child)) { childName = DOMUtil.getLocalName(child); if (childName.equals(SchemaSymbols.ELT_ATTRIBUTE)) { tempAttrUse = fSchemaHandler.fAttributeTraverser.traverseLocal(child, schemaDoc, grammar, enclosingCT); if (tempAttrUse == null) break; if (attrGrp.getAttributeUse(tempAttrUse.fAttrDecl.getNamespace(), tempAttrUse.fAttrDecl.getName())==null) { String idName = attrGrp.addAttributeUse(tempAttrUse); if (idName != null) { String code = (enclosingCT == null) ? "ag-props-correct.3" : "ct-props-correct.5"; String name = (enclosingCT == null) ? attrGrp.fName : enclosingCT.getName(); reportSchemaError(code, new Object[]{name, tempAttrUse.fAttrDecl.getName(), idName}, child); } } else { // REVISIT: what if one of the attribute uses is "prohibited" String code = (enclosingCT == null) ? "ag-props-correct.2" : "ct-props-correct.4"; String name = (enclosingCT == null) ? attrGrp.fName : enclosingCT.getName(); reportSchemaError(code, new Object[]{name, tempAttrUse.fAttrDecl.getName()}, child); } } else if (childName.equals(SchemaSymbols.ELT_ATTRIBUTEGROUP)) { //REVISIT: do we need to save some state at this point?? tempAttrGrp = fSchemaHandler.fAttributeGroupTraverser.traverseLocal( child, schemaDoc, grammar); if(tempAttrGrp == null ) break; XSObjectList attrUseS = tempAttrGrp.getAttributeUses(); XSAttributeUseImpl existingAttrUse = null, oneAttrUse; int attrCount = attrUseS.getLength(); for (int i=0; i<attrCount; i++) { oneAttrUse = (XSAttributeUseImpl)attrUseS.item(i); if (existingAttrUse == attrGrp.getAttributeUse(oneAttrUse.fAttrDecl.getNamespace(), oneAttrUse.fAttrDecl.getName())) { String idName = attrGrp.addAttributeUse(oneAttrUse); if (idName != null) { String code = (enclosingCT == null) ? "ag-props-correct.3" : "ct-props-correct.5"; String name = (enclosingCT == null) ? attrGrp.fName : enclosingCT.getName(); reportSchemaError(code, new Object[]{name, oneAttrUse.fAttrDecl.getName(), idName}, child); } } else { // REVISIT: what if one of the attribute uses is "prohibited" String code = (enclosingCT == null) ? "ag-props-correct.2" : "ct-props-correct.4"; String name = (enclosingCT == null) ? attrGrp.fName : enclosingCT.getName(); reportSchemaError(code, new Object[]{name, oneAttrUse.fAttrDecl.getName()}, child); } } if (tempAttrGrp.fAttributeWC != null) { if (attrGrp.fAttributeWC == null) { attrGrp.fAttributeWC = tempAttrGrp.fAttributeWC; } // perform intersection of attribute wildcard else { attrGrp.fAttributeWC = attrGrp.fAttributeWC. performIntersectionWith(tempAttrGrp.fAttributeWC, attrGrp.fAttributeWC.fProcessContents); if (attrGrp.fAttributeWC == null) { String code = (enclosingCT == null) ? "src-attribute_group.2" : "src-ct.4"; String name = (enclosingCT == null) ? attrGrp.fName : enclosingCT.getName(); reportSchemaError(code, new Object[]{name}, child); } } } } else break; } // for if (child != null) { childName = DOMUtil.getLocalName(child); if (childName.equals(SchemaSymbols.ELT_ANYATTRIBUTE)) { XSWildcardDecl tempAttrWC = fSchemaHandler.fWildCardTraverser. traverseAnyAttribute(child, schemaDoc, grammar); if (attrGrp.fAttributeWC == null) { attrGrp.fAttributeWC = tempAttrWC; } // perform intersection of attribute wildcard else { attrGrp.fAttributeWC = tempAttrWC. performIntersectionWith(attrGrp.fAttributeWC, tempAttrWC.fProcessContents); if (attrGrp.fAttributeWC == null) { String code = (enclosingCT == null) ? "src-attribute_group.2" : "src-ct.4"; String name = (enclosingCT == null) ? attrGrp.fName : enclosingCT.getName(); reportSchemaError(code, new Object[]{name}, child); } } child = DOMUtil.getNextSiblingElement(child); } } // Success return child; } void reportSchemaError (String key, Object[] args, Element ele) { fSchemaHandler.reportSchemaError(key, args, ele); } /** * Element/Attribute traversers call this method to check whether * the type is NOTATION without enumeration facet */ void checkNotationType(String refName, XSTypeDefinition typeDecl, Element elem) { if (typeDecl.getTypeCategory() == XSTypeDefinition.SIMPLE_TYPE && ((XSSimpleType)typeDecl).getVariety() == XSSimpleType.VARIETY_ATOMIC && ((XSSimpleType)typeDecl).getPrimitiveKind() == XSSimpleType.PRIMITIVE_NOTATION) { if ((((XSSimpleType)typeDecl).getDefinedFacets() & XSSimpleType.FACET_ENUMERATION) == 0) { reportSchemaError("enumeration-required-notation", new Object[]{typeDecl.getName(), refName, DOMUtil.getLocalName(elem)}, elem); } } } // Checks constraints for minOccurs, maxOccurs protected XSParticleDecl checkOccurrences(XSParticleDecl particle, String particleName, Element parent, int allContextFlags, long defaultVals) { int min = particle.fMinOccurs; int max = particle.fMaxOccurs; boolean defaultMin = (defaultVals & (1 << XSAttributeChecker.ATTIDX_MINOCCURS)) != 0; boolean defaultMax = (defaultVals & (1 << XSAttributeChecker.ATTIDX_MAXOCCURS)) != 0; boolean processingAllEl = ((allContextFlags & PROCESSING_ALL_EL) != 0); boolean processingAllGP = ((allContextFlags & PROCESSING_ALL_GP) != 0); boolean groupRefWithAll = ((allContextFlags & GROUP_REF_WITH_ALL) != 0); boolean isGroupChild = ((allContextFlags & CHILD_OF_GROUP) != 0); // Neither minOccurs nor maxOccurs may be specified // for the child of a model group definition. if (isGroupChild) { if (!defaultMin) { Object[] args = new Object[]{particleName, "minOccurs"}; reportSchemaError("s4s-att-not-allowed", args, parent); min = 1; } if (!defaultMax) { Object[] args = new Object[]{particleName, "maxOccurs"}; reportSchemaError("s4s-att-not-allowed", args, parent); max = 1; } } // If minOccurs=maxOccurs=0, no component is specified if (min == 0 && max== 0) { particle.fType = XSParticleDecl.PARTICLE_EMPTY; return null; } // For the elements referenced in an <all>, minOccurs attribute // must be zero or one, and maxOccurs attribute must be one. // For a complex type definition that contains an <all> or a // reference a <group> whose model group is an all model group, // minOccurs and maxOccurs must be one. if (processingAllEl) { if (max != 1) { reportSchemaError("cos-all-limited.2", new Object[]{new Integer(max), ((XSElementDecl)particle.fValue).getName()}, parent); max = 1; if (min > 1) min = 1; } } else if (processingAllGP || groupRefWithAll) { if (max != 1) { reportSchemaError("cos-all-limited.1.2", null, parent); if (min > 1) min = 1; max = 1; } } particle.fMaxOccurs = min; particle.fMaxOccurs = max; return particle; } // this is not terribly performant! private static String processAttValue(String original) { // normally, nothing will happen StringBuffer newVal = new StringBuffer(original.length()); for(int i=0; i<original.length(); i++) { char currChar = original.charAt(i); if(currChar == '"') { newVal.append("""); } else if (currChar == '>') { newVal.append(">"); } else if (currChar == '&') { newVal.append("&"); } else { newVal.append(currChar); } } return newVal.toString(); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -