Package org.apache.xerces.impl.xs.identity

Examples of org.apache.xerces.impl.xs.identity.IdentityConstraint


            // handle everything *but* keyref's.
            for (int i = oldCount - 1; i >= newCount; i--) {
                XPathMatcher matcher = fMatcherStack.getMatcherAt(i);
                if (matcher instanceof Selector.Matcher) {
                    Selector.Matcher selMatcher = (Selector.Matcher) matcher;
                    IdentityConstraint id;
                    if ((id = selMatcher.getIdentityConstraint()) != null
                            && id.getCategory() != IdentityConstraint.IC_KEYREF) {
                        fValueStoreCache.transplant(id, selMatcher.getInitialDepth());
                    }
                }
            }
           
            // now handle keyref's/...
            for (int i = oldCount - 1; i >= newCount; i--) {
                XPathMatcher matcher = fMatcherStack.getMatcherAt(i);
                if (matcher instanceof Selector.Matcher) {
                    Selector.Matcher selMatcher = (Selector.Matcher) matcher;
                    IdentityConstraint id;
                    if ((id = selMatcher.getIdentityConstraint()) != null
                            && id.getCategory() == IdentityConstraint.IC_KEYREF) {
                        ValueStoreBase values =
                            fValueStoreCache.getValueStoreFor(id, selMatcher.getInitialDepth());
                        if (values != null) // nothing to do if nothing matched!
                            values.endDocumentFragment();
                    }
View Full Code Here


            }

            Iterator entries = oldMap.entrySet().iterator();
            while (entries.hasNext()) {
                Map.Entry entry = (Map.Entry) entries.next();
                IdentityConstraint id = (IdentityConstraint) entry.getKey();
                ValueStoreBase oldVal = (ValueStoreBase) entry.getValue();
                if (oldVal != null) {
                    ValueStoreBase currVal = (ValueStoreBase) fGlobalIDConstraintMap.get(id);
                    if (currVal == null) {
                        fGlobalIDConstraintMap.put(id, oldVal);
View Full Code Here

            if (oldMap == null)
                return;

            Enumeration keys = oldMap.keys();
            while (keys.hasMoreElements()) {
                IdentityConstraint id = (IdentityConstraint) keys.nextElement();
                ValueStoreBase oldVal = (ValueStoreBase) oldMap.get(id);
                if (oldVal != null) {
                    ValueStoreBase currVal = (ValueStoreBase) fGlobalIDConstraintMap.get(id);
                    if (currVal == null)
                        fGlobalIDConstraintMap.put(id, oldVal);
View Full Code Here

            // handle everything *but* keyref's.
            for (int i = oldCount - 1; i >= newCount; i--) {
                XPathMatcher matcher = fMatcherStack.getMatcherAt(i);
                if (matcher instanceof Selector.Matcher) {
                    Selector.Matcher selMatcher = (Selector.Matcher) matcher;
                    IdentityConstraint id;
                    if ((id = selMatcher.getIdentityConstraint()) != null
                            && id.getCategory() != IdentityConstraint.IC_KEYREF) {
                        fValueStoreCache.transplant(id, selMatcher.getInitialDepth());
                    }
                }
            }
           
            // now handle keyref's/...
            for (int i = oldCount - 1; i >= newCount; i--) {
                XPathMatcher matcher = fMatcherStack.getMatcherAt(i);
                if (matcher instanceof Selector.Matcher) {
                    Selector.Matcher selMatcher = (Selector.Matcher) matcher;
                    IdentityConstraint id;
                    if ((id = selMatcher.getIdentityConstraint()) != null
                            && id.getCategory() == IdentityConstraint.IC_KEYREF) {
                        ValueStoreBase values =
                            fValueStoreCache.getValueStoreFor(id, selMatcher.getInitialDepth());
                        if (values != null) // nothing to do if nothing matched!
                            values.endDocumentFragment();
                    }
View Full Code Here

         XSNamedMap idConstraintsMap = elemDecl.getIdentityConstraints();
        
         // iterate all identity constraints on an element declaration
         for (int idConsIdx = 0; idConsIdx < idConstraintsMap.getLength();
                                               idConsIdx++) {
             IdentityConstraint idCons = (IdentityConstraint)
                                           idConstraintsMap.item(idConsIdx);
             String consType = null;
             String idReferStr = null;            
             if (idCons.getCategory() == XSIDCDefinition.IC_UNIQUE) {
                 consType = "unique"
             }
             else if (idCons.getCategory() == XSIDCDefinition.IC_KEY) {
                 consType = "key";   
             }
             else if (idCons.getCategory() == XSIDCDefinition.IC_KEYREF) {
                 consType = "keyref";
                 idReferStr = (((KeyRef) idCons).getKey()).getName();
             }
            
             Element idConsDomNode = document.createElementNS(XSD_LANGUAGE_URI,
                                                           XSD_LANGUAGE_PREFIX
                                                           + consType);
             String idConsName = idCons.getName();
             idConsDomNode.setAttributeNS(null, "name", idConsName);
            
             if (idReferStr != null) {
                idConsDomNode.setAttributeNS(null, "refer", idReferStr)
             }
            
             // add annotation to an ID constraint
             XSAnnotationImpl idConsAnnotation = (XSAnnotationImpl)
                                                   idCons.getAnnotations().item(0);
             if (idConsAnnotation != null) {
                addAnnotationToSchemaComponent(document,
                                               idConsDomNode,
                                               idConsAnnotation);
             }
            
             Selector idSelector = idCons.getSelector();
             String selectorXPathStr = idSelector.getXPath().toString();
             Element selectorDomNode = document.createElementNS(XSD_LANGUAGE_URI,
                                                              XSD_LANGUAGE_PREFIX
                                                              + "selector");
             selectorDomNode.setAttributeNS(null, "xpath", selectorXPathStr);
             idConsDomNode.appendChild(selectorDomNode);            
            
             for (int fieldIdx = 0; fieldIdx < idCons.getFieldCount(); fieldIdx++) {
                Field field = idCons.getFieldAt(fieldIdx);
                String fieldXpathStr = field.getXPath().toString();
                Element fieldDomNode = document.createElementNS(XSD_LANGUAGE_URI,
                                                                XSD_LANGUAGE_PREFIX
                                                                + "field");
                fieldDomNode.setAttributeNS(null, "xpath", fieldXpathStr);
View Full Code Here

    
        // General Attribute Checking
        Object[] attrValues = fAttrChecker.checkAttributes(icElem, false, schemaDoc);       
        QName referredIcQName = (QName)attrValues[XSAttributeChecker.ATTIDX_REF];
       
        IdentityConstraint referredIc = (IdentityConstraint)fSchemaHandler.getGlobalDecl(schemaDoc, XSDHandler.IDENTITYCONSTRAINT_TYPE, referredIcQName, icElem);
        // TODO: If the referredIc had a problem such as the refer attribute did not resolve to a unique/key,
        //       the referredIc will not have been built but it will be hidden.
        //       When we try to get its declaration, it will display Internal error.
        //       Same thing happens when a keyref has refer attribute which is its own name.  But the internal error would be correct.
       
        if (referredIc == null) {
            fAttrChecker.returnAttrArray(attrValues, schemaDoc);
            return;
        }
       
        short referralIcCategory;
        String icCategoryName = DOMUtil.getLocalName(icElem);
       
        // Check that the category of referred ic is same as this
        if (icCategoryName.equals(SchemaSymbols.ELT_UNIQUE)) {
            referralIcCategory = IdentityConstraint.IC_UNIQUE;
        } else if (icCategoryName.equals(SchemaSymbols.ELT_KEY)) {
            referralIcCategory = IdentityConstraint.IC_KEY;
        } else {
            referralIcCategory = IdentityConstraint.IC_KEYREF;
        }
       
        if (referredIc.getCategory() != referralIcCategory) {
            reportSchemaError("src-identity-constraint.5", new Object[]{DOMUtil.getLocalName(icElem)}, icElem);
            fAttrChecker.returnAttrArray(attrValues, schemaDoc);
            return;
        }
       
View Full Code Here

            if (grammar.getIDConstraintDecl(uniqueOrKey.getIdentityConstraintName()) == null) {
                grammar.addIDConstraintDecl(element, uniqueOrKey);
            }

            final String loc = fSchemaHandler.schemaDocument2SystemId(schemaDoc);
            final IdentityConstraint idc = grammar.getIDConstraintDecl(uniqueOrKey.getIdentityConstraintName(), loc)
            if (idc == null) {
                grammar.addIDConstraintDecl(element, uniqueOrKey, loc);
            }

            // handle duplicates
View Full Code Here

            fAttrChecker.returnAttrArray(attrValues, schemaDoc);
            return;
        }

        UniqueOrKey key = null;
        IdentityConstraint ret = (IdentityConstraint)fSchemaHandler.getGlobalDecl(schemaDoc, XSDHandler.IDENTITYCONSTRAINT_TYPE, kName, krElem);
        // if ret == null, we've already reported an error in getGlobalDecl
        // we report an error only when ret != null, and the return type keyref
        if (ret != null) {
            if (ret.getCategory() == IdentityConstraint.IC_KEY ||
                ret.getCategory() == IdentityConstraint.IC_UNIQUE) {
                key = (UniqueOrKey)ret;
            } else {
                reportSchemaError("src-resolve", new Object[]{kName.rawname, "identity constraint key/unique"}, krElem);
            }
        }

        if(key == null) {
            fAttrChecker.returnAttrArray(attrValues, schemaDoc);
            return;
        }

        KeyRef keyRef = new KeyRef(schemaDoc.fTargetNamespace, krName, key);

        // If errors occurred in traversing the identity constraint, then don't
        // add it to the schema, to avoid errors when processing the instance.
        if (traverseIdentityConstraint(keyRef, krElem, schemaDoc, attrValues)) {
            //Schema Component Constraint: Identity-constraint Definition Properties Correct
            //2 If the {identity-constraint category} is keyref, the cardinality of the {fields} must equal that of the {fields} of the {referenced key}.
            if(key.getFieldCount() != keyRef.getFieldCount()) {
                reportSchemaError("c-props-correct.2" , new Object [] {krName,key.getIdentityConstraintName()}, krElem);
            } else {
                // add key reference to element decl
                // and stuff this in the grammar
                if (grammar.getIDConstraintDecl(keyRef.getIdentityConstraintName()) == null) {
                    grammar.addIDConstraintDecl(element, keyRef);
                }

                // also add it to extended map
                final String loc = fSchemaHandler.schemaDocument2SystemId(schemaDoc);
                final IdentityConstraint idc = grammar.getIDConstraintDecl(keyRef.getIdentityConstraintName(), loc);
                if (idc  == null) {
                    grammar.addIDConstraintDecl(element, keyRef, loc);
                }

                // handle duplicates
View Full Code Here

         XSNamedMap idConstraintsMap = elemDecl.getIdentityConstraints();
        
         // iterate all identity constraints on an element declaration
         for (int idConsIdx = 0; idConsIdx < idConstraintsMap.getLength();
                                               idConsIdx++) {
             IdentityConstraint idCons = (IdentityConstraint)
                                           idConstraintsMap.item(idConsIdx);
             String consType = null;
             String idReferStr = null;            
             if (idCons.getCategory() == XSIDCDefinition.IC_UNIQUE) {
                 consType = "unique"
             }
             else if (idCons.getCategory() == XSIDCDefinition.IC_KEY) {
                 consType = "key";   
             }
             else if (idCons.getCategory() == XSIDCDefinition.IC_KEYREF) {
                 consType = "keyref";
                 idReferStr = (((KeyRef) idCons).getKey()).getName();
             }
            
             Element idConsDomNode = document.createElementNS(XSD_LANGUAGE_URI,
                                                           XSD_LANGUAGE_PREFIX
                                                           + consType);
             String idConsName = idCons.getName();
             idConsDomNode.setAttributeNS(null, "name", idConsName);
            
             if (idReferStr != null) {
                idConsDomNode.setAttributeNS(null, "refer", idReferStr)
             }
            
             // add annotation to an ID constraint
             XSAnnotationImpl idConsAnnotation = (XSAnnotationImpl)
                                                   idCons.getAnnotations().item(0);
             if (idConsAnnotation != null) {
                addAnnotationToSchemaComponent(document,
                                               idConsDomNode,
                                               idConsAnnotation);
             }
            
             Selector idSelector = idCons.getSelector();
             String selectorXPathStr = idSelector.getXPath().toString();
             Element selectorDomNode = document.createElementNS(XSD_LANGUAGE_URI,
                                                              XSD_LANGUAGE_PREFIX
                                                              + "selector");
             selectorDomNode.setAttributeNS(null, "xpath", selectorXPathStr);
             idConsDomNode.appendChild(selectorDomNode);            
            
             for (int fieldIdx = 0; fieldIdx < idCons.getFieldCount(); fieldIdx++) {
                Field field = idCons.getFieldAt(fieldIdx);
                String fieldXpathStr = field.getXPath().toString();
                Element fieldDomNode = document.createElementNS(XSD_LANGUAGE_URI,
                                                                XSD_LANGUAGE_PREFIX
                                                                + "field");
                fieldDomNode.setAttributeNS(null, "xpath", fieldXpathStr);
View Full Code Here

            // handle everything *but* keyref's.
            for (int i = oldCount - 1; i >= newCount; i--) {
                XPathMatcher matcher = fMatcherStack.getMatcherAt(i);
                if (matcher instanceof Selector.Matcher) {
                    Selector.Matcher selMatcher = (Selector.Matcher) matcher;
                    IdentityConstraint id;
                    if ((id = selMatcher.getIdentityConstraint()) != null
                            && id.getCategory() != IdentityConstraint.IC_KEYREF) {
                        fValueStoreCache.transplant(id, selMatcher.getInitialDepth());
                    }
                }
            }
           
            // now handle keyref's/...
            for (int i = oldCount - 1; i >= newCount; i--) {
                XPathMatcher matcher = fMatcherStack.getMatcherAt(i);
                if (matcher instanceof Selector.Matcher) {
                    Selector.Matcher selMatcher = (Selector.Matcher) matcher;
                    IdentityConstraint id;
                    if ((id = selMatcher.getIdentityConstraint()) != null
                            && id.getCategory() == IdentityConstraint.IC_KEYREF) {
                        ValueStoreBase values =
                            fValueStoreCache.getValueStoreFor(id, selMatcher.getInitialDepth());
                        if (values != null) // nothing to do if nothing matched!
                            values.endDocumentFragment();
                    }
View Full Code Here

TOP

Related Classes of org.apache.xerces.impl.xs.identity.IdentityConstraint

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.