Package org.apache.xerces.xni.psvi

Examples of org.apache.xerces.xni.psvi.AttributePSVI


                String attrValue = attributes.getValue(i);
                // REVISIT: consider moving this code to the XML Schema validator.
                //          When PSVI and XML Schema component interfaces are finalized
                //          remove dependancy on *Impl class.
                AttributePSVI attrPSVI = (AttributePSVI)attributes.getAugmentations(i).getItem(Constants.ATTRIBUTE_PSVI);
                if (fStorePSVI && attrPSVI != null) {
                    ((PSVIAttrNSImpl)attr).setPSVI(attrPSVI);
                }
                if (fNormalizeData) {
                    // If validation is not attempted, the SchemaNormalizedValue will be null.
                    // We shouldn't take the normalized value in this case.
                    if (attrPSVI != null && attrPSVI.getValidationAttempted() == AttributePSVI.VALIDATION_FULL) {
                        attrValue = attrPSVI.getSchemaNormalizedValue();
                    }

                }
               
                attr.setValue(attrValue);
                el.setAttributeNode(attr);
                // NOTE: The specified value MUST be set after you set
                //       the node value because that turns the "specified"
                //       flag to "true" which may overwrite a "false"
                //       value from the attribute list. -Ac
                if (fDocumentImpl != null) {
                    AttrImpl attrImpl = (AttrImpl)attr;
                    boolean specified = attributes.isSpecified(i);
                    attrImpl.setSpecified(specified);
                    // Identifier registration
                    // REVISIT: try to retrieve XML Schema attribute declaration
                    //          we should try to modify psvi API to allows to
                    //          check if id type
                    XSAttributeDeclaration xsDecl = (XSAttributeDeclaration)((attrPSVI!=null)?attrPSVI.getAttributeDeclaration():null);
                    if (attributes.getType(i).equals("ID") ||
                        (xsDecl !=null && ((XSSimpleType)xsDecl.getTypeDefinition()).isIDType())) {
                        ((ElementImpl) el).setIdAttributeNode(attr);
                    }
                }
                // REVISIT: Handle entities in attribute value.
            }

            setCharacterData(false);
            // filter nodes
            if (fDOMFilter != null) {
                short code = fDOMFilter.startElement(el);
                switch (code) {
                    case DOMBuilderFilter.FILTER_INTERRUPT:{
                        throw new RuntimeException("The normal processing of the document was interrupted.");
                    }  
                    case DOMBuilderFilter.FILTER_REJECT:{
                        fFilterReject = true;
                        fRejectedElement.setValues(element);
                        return;
                    }
                    case DOMBuilderFilter.FILTER_SKIP: {
                        fSkippedElemStack.push(element);
                        return;
                    }
                    default: {
                    }
                }
            }

            fCurrentNode.appendChild(el);
            fCurrentNode = el;
        }
        else {
            int el =
                fDeferredDocumentImpl.createDeferredElement(fNamespaceAware ?
                                                            element.uri : null,
                                                            element.rawname);
            int attrCount = attributes.getLength();
            for (int i = 0; i < attrCount; i++) {
                String attrValue = attributes.getValue(i);
                // REVISIT: consider moving this code to the XML Schema validator.
                //          When PSVI and XML Schema component interfaces are finalized
                //          remove dependancy on *Impl class.
                AttributePSVI attrPSVI = (AttributePSVI)attributes.getAugmentations(i).getItem(Constants.ATTRIBUTE_PSVI);
               
                if (fNormalizeData) {
                    // If validation is not attempted, the SchemaNormalizedValue will be null.
                    // We shouldn't take the normalized value in this case.
                    if (attrPSVI != null && attrPSVI.getValidationAttempted() == AttributePSVI.VALIDATION_FULL) {
                        attrValue = attrPSVI.getSchemaNormalizedValue();
                    }

                }
                int attr = fDeferredDocumentImpl.setDeferredAttribute(el,
                                                    attributes.getQName(i),
                                                    attributes.getURI(i),
                                                    attrValue,
                                                    attributes.isSpecified(i));
                // identifier registration
                // REVISIT: try to retrieve XML Schema attribute declaration
                //          we should try to modify psvi API to allows to
                //          check if id type
                XSAttributeDeclaration xsDecl = (XSAttributeDeclaration)((attrPSVI!=null)?attrPSVI.getAttributeDeclaration():null);
               
                if (attributes.getType(i).equals("ID") ||
                    (xsDecl !=null && ((XSSimpleType)xsDecl.getTypeDefinition()).isIDType())) {
                    fDeferredDocumentImpl.setIdAttributeNode(el, attr);
                }
View Full Code Here


                String attrValue = attributes.getValue(i);
                // REVISIT: consider moving this code to the XML Schema validator.
                //          When PSVI and XML Schema component interfaces are finalized
                //          remove dependancy on *Impl class.
                AttributePSVI attrPSVI = (AttributePSVI)attributes.getAugmentations(i).getItem(Constants.ATTRIBUTE_PSVI);
                if (fStorePSVI && attrPSVI != null) {
                    ((PSVIAttrNSImpl)attr).setPSVI(attrPSVI);
                }
                if (fNormalizeData) {
                    // If validation is not attempted, the SchemaNormalizedValue will be null.
                    // We shouldn't take the normalized value in this case.
                    if (attrPSVI != null && attrPSVI.getValidationAttempted() == AttributePSVI.VALIDATION_FULL) {
                        attrValue = attrPSVI.getSchemaNormalizedValue();
                    }

                }
               
                attr.setValue(attrValue);
                el.setAttributeNode(attr);
                // NOTE: The specified value MUST be set after you set
                //       the node value because that turns the "specified"
                //       flag to "true" which may overwrite a "false"
                //       value from the attribute list. -Ac
                if (fDocumentImpl != null) {
                    AttrImpl attrImpl = (AttrImpl)attr;
                    boolean specified = attributes.isSpecified(i);
                    attrImpl.setSpecified(specified);
                    // Identifier registration
                    // REVISIT: try to retrieve XML Schema attribute declaration
                    //          we should try to modify psvi API to allows to
                    //          check if id type
                    XSAttributeDeclaration xsDecl = (XSAttributeDeclaration)((attrPSVI!=null)?attrPSVI.getAttributeDeclaration():null);
                    if (attributes.getType(i).equals("ID") ||
                        (xsDecl !=null && ((XSSimpleType)xsDecl.getTypeDefinition()).isIDType())) {
                        ((ElementImpl) el).setIdAttributeNode(attr);
                    }
                }
                // REVISIT: Handle entities in attribute value.
            }

            setCharacterData(false);
            // filter nodes
            if (fDOMFilter != null) {
                short code = fDOMFilter.startElement(el);
                switch (code) {
                    case DOMBuilderFilter.FILTER_INTERRUPT:{
                        throw new RuntimeException("The normal processing of the document was interrupted.");
                    }  
                    case DOMBuilderFilter.FILTER_REJECT:{
                        fFilterReject = true;
                        fRejectedElement.setValues(element);
                        return;
                    }
                    case DOMBuilderFilter.FILTER_SKIP: {
                        fSkippedElemStack.push(element);
                        return;
                    }
                    default: {
                    }
                }
            }

            fCurrentNode.appendChild(el);
            fCurrentNode = el;
        }
        else {
            int el =
                fDeferredDocumentImpl.createDeferredElement(fNamespaceAware ?
                                                            element.uri : null,
                                                            element.rawname);
            int attrCount = attributes.getLength();
            for (int i = 0; i < attrCount; i++) {
                String attrValue = attributes.getValue(i);
                // REVISIT: consider moving this code to the XML Schema validator.
                //          When PSVI and XML Schema component interfaces are finalized
                //          remove dependancy on *Impl class.
                AttributePSVI attrPSVI = (AttributePSVI)attributes.getAugmentations(i).getItem(Constants.ATTRIBUTE_PSVI);
               
                if (fNormalizeData) {
                    // If validation is not attempted, the SchemaNormalizedValue will be null.
                    // We shouldn't take the normalized value in this case.
                    if (attrPSVI != null && attrPSVI.getValidationAttempted() == AttributePSVI.VALIDATION_FULL) {
                        attrValue = attrPSVI.getSchemaNormalizedValue();
                    }

                }
                int attr = fDeferredDocumentImpl.setDeferredAttribute(el,
                                                    attributes.getQName(i),
                                                    attributes.getURI(i),
                                                    attrValue,
                                                    attributes.isSpecified(i));
                // identifier registration
                // REVISIT: try to retrieve XML Schema attribute declaration
                //          we should try to modify psvi API to allows to
                //          check if id type
                XSAttributeDeclaration xsDecl = (XSAttributeDeclaration)((attrPSVI!=null)?attrPSVI.getAttributeDeclaration():null);
               
                if (attributes.getType(i).equals("ID") ||
                    (xsDecl !=null && ((XSSimpleType)xsDecl.getTypeDefinition()).isIDType())) {
                    fDeferredDocumentImpl.setIdAttributeNode(el, attr);
                }
View Full Code Here

        }
    }

    public void printPSVIAttribute(Augmentations augs) {
        AttributePSVI attrPSVI =(AttributePSVI)augs.getItem(Constants.ATTRIBUTE_PSVI);
        if (attrPSVI !=null) {

            printElement("psv:validationContext",attrPSVI.getValidationContext());

            short validity = attrPSVI.getValidity();
            if (validity == ItemPSVI.VALIDITY_UNKNOWN) {
                printElement("psv:validity","unknown");
            }
            else if (validity == ItemPSVI.VALIDITY_VALID) {
                printElement("psv:validity","valid");
            }
            else if (validity == ItemPSVI.VALIDITY_INVALID) {
                printElement("psv:validity","invalid");
            }

            short validation = attrPSVI.getValidationAttempted();
            if (validation == ItemPSVI.VALIDATION_NONE) {
                printElement("psv:validationAttempted","none");
                return;
            }
            else if (validation == ItemPSVI.VALIDATION_FULL) {
                printElement("psv:validationAttempted","full");
            }

            StringList errorCode = attrPSVI.getErrorCodes();
            if (errorCode == null) {
                printElement("psv:schemaErrorCode","");
            }
            else {
                for (int i=0;i<errorCode.getLength();i++) {
                    fErrorBuffer.append(errorCode.item(i));
                }               
                printElement("psv:schemaErrorCode",fErrorBuffer.toString());
                fErrorBuffer.setLength(0);

            }

            printElement("psv:schemaNormalizedValue",attrPSVI.getSchemaNormalizedValue());
            printElement("psv:schemaSpecified", (attrPSVI.getIsSchemaSpecified())?"schema":"infoset");

            XSTypeDefinition type = attrPSVI.getTypeDefinition();
            XSSimpleTypeDefinition memtype = attrPSVI.getMemberTypeDefinition();
            short definationType = type.getTypeCategory();
            if (definationType == XSTypeDecl.SIMPLE_TYPE) {
                printElement("psv:typeDefinitionType","simple");
            }
View Full Code Here

                Attr attr = createAttrNode(fAttrQName);

                String attrValue = attributes.getValue(i);
                // REVISIT: Should this happen here ? Why not in schema validator?
                if (fNormalizeData) {
                    AttributePSVI attrPSVI = (AttributePSVI)attributes.getAugmentations(i).getItem(Constants.ATTRIBUTE_PSVI);
                    // If validation is not attempted, the SchemaNormalizedValue will be null.
                    // We shouldn't take the normalized value in this case.
                    if (attrPSVI != null && attrPSVI.getValidationAttempted() == AttributePSVI.FULL_VALIDATION) {
                        attrValue = attrPSVI.getSchemaNormalizedValue();
                    }

                }
                attr.setValue(attrValue);
                el.setAttributeNode(attr);
                // NOTE: The specified value MUST be set after you set
                //       the node value because that turns the "specified"
                //       flag to "true" which may overwrite a "false"
                //       value from the attribute list. -Ac
                if (fDocumentImpl != null) {
                    AttrImpl attrImpl = (AttrImpl)attr;
                    boolean specified = attributes.isSpecified(i);
                    attrImpl.setSpecified(specified);
                    // identifier registration
                    if (attributes.getType(i).equals("ID")) {
                        fDocumentImpl.putIdentifier(attrValue, el);
                    }
                }
                // REVISIT: Handle entities in attribute value.
            }
            fCurrentNode.appendChild(el);
            fCurrentNode = el;
        }
        else {
            int el =
                fDeferredDocumentImpl.createDeferredElement(fNamespaceAware ?
                                                            element.uri : null,
                                                            element.rawname);
            int attrCount = attributes.getLength();
            for (int i = 0; i < attrCount; i++) {
                String attrValue = attributes.getValue(i);
                // REVISIT: Should this happen here ? Why not in schema validator?
                if (fNormalizeData) {
                    AttributePSVI attrPSVI = (AttributePSVI)attributes.getAugmentations(i).getItem(Constants.ATTRIBUTE_PSVI);
                    // If validation is not attempted, the SchemaNormalizedValue will be null.
                    // We shouldn't take the normalized value in this case.
                    if (attrPSVI != null && attrPSVI.getValidationAttempted() == AttributePSVI.FULL_VALIDATION) {
                        attrValue = attrPSVI.getSchemaNormalizedValue();
                    }

                }
                fDeferredDocumentImpl.setDeferredAttribute(el,
                                                    attributes.getQName(i),
View Full Code Here

                for (int i = len - 1; i >= 0; i--) {
                    attributes.getName(i, fQName);
                    // change attribute value to normalized value
                    // REVISIT: should this happen here? why not in schema validator?
                    if (fNormalizeData) {
                        AttributePSVI attrPSVI = (AttributePSVI)attributes.getAugmentations(i).getItem(Constants.ATTRIBUTE_PSVI);
                        if (attrPSVI != null &&
                            attrPSVI.getValidationAttempted() == AttributePSVI.FULL_VALIDATION) {
                            attributes.setValue(i, attrPSVI.getSchemaNormalizedValue());
                        }
                    }

                    if ((fQName.prefix != null && fQName.prefix.equals("xmlns")) ||
                        fQName.rawname.equals("xmlns")) {
View Full Code Here

                int len = attributes.getLength();
                for (int i = len - 1; i >= 0; i--) {
                    attributes.getName(i, fQName);
                    // change attribute value to normalized value
                    if (fNormalizeData) {
                        AttributePSVI attrPSVI = (AttributePSVI)attributes.getAugmentations(i).getItem(Constants.ATTRIBUTE_PSVI);
                        if (attrPSVI != null) {
                            attributes.setValue(i, attrPSVI.getSchemaNormalizedValue());
                        }
                    }

                    if (fQName.prefix == fXmlnsSymbol ||
                        fQName.rawname == fXmlnsSymbol) {
View Full Code Here

                    attr = fDocument.createAttribute(fAttrQName.rawname);
                }

                String attrValue = attributes.getValue(i);
                if (fNormalizeData) {
                    AttributePSVI attrPSVI = (AttributePSVI)attributes.getAugmentations(i).getItem(Constants.ATTRIBUTE_PSVI);
                    if (attrPSVI != null) {
                        attrValue = attrPSVI.getSchemaNormalizedValue();
                    }

                }
                attr.setValue(attrValue);
                el.setAttributeNode(attr);
                // NOTE: The specified value MUST be set after you set
                //       the node value because that turns the "specified"
                //       flag to "true" which may overwrite a "false"
                //       value from the attribute list. -Ac
                if (fDocumentImpl != null) {
                    AttrImpl attrImpl = (AttrImpl)attr;
                    boolean specified = attributes.isSpecified(i);
                    attrImpl.setSpecified(specified);
        // identifier registration
        if (attributes.getType(i).equals("ID")) {
                        fDocumentImpl.putIdentifier(attrValue, el);
                    }
                }
                // REVISIT: Handle entities in attribute value.
            }
            fCurrentNode.appendChild(el);
            fCurrentNode = el;
        }
        else {
            int el =
    fDeferredDocumentImpl.createDeferredElement(fNamespaceAware ?
                  element.uri : null,
                  element.rawname);
            int attrCount = attributes.getLength();
            for (int i = 0; i < attrCount; i++) {
    String attrValue = attributes.getValue(i);
                if (fNormalizeData) {
                    AttributePSVI attrPSVI = (AttributePSVI)attributes.getAugmentations(i).getItem(Constants.ATTRIBUTE_PSVI);
                    if (attrPSVI != null) {
                        attrValue = attrPSVI.getSchemaNormalizedValue();
                    }

                }
    fDeferredDocumentImpl.setDeferredAttribute(el,
                attributes.getQName(i),
View Full Code Here

TOP

Related Classes of org.apache.xerces.xni.psvi.AttributePSVI

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.