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 (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);
            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 (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);
            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

    for (int i = 0; i < attrCount; i++) {
      attributes.getName(i, fAttrQName);
      Attr attr = null;

      attr = currentElement.getAttributeNodeNS(fAttrQName.uri, fAttrQName.localpart);
            AttributePSVI attrPSVI =
        (AttributePSVI) attributes.getAugmentations(i).getItem(Constants.ATTRIBUTE_PSVI);

      if (attrPSVI != null) {
                //REVISIT: instead we should be using augmentations:
                // to set/retrieve Id attributes
                XSTypeDefinition decl = attrPSVI.getMemberTypeDefinition();
                boolean id = false;
                if (decl != null){
                    id = ((XSSimpleType)decl).isIDType();
                } else{
                    decl = attrPSVI.getTypeDefinition();
                    if (decl !=null){
                       id = ((XSSimpleType)decl).isIDType();
                    }
                }
                if (id){
                    ((ElementImpl)currentElement).setIdAttributeNode(attr, true);
                }
               
        if (fPSVI) {
          ((PSVIAttrNSImpl) attr).setPSVI(attrPSVI);
        }
        if ((fConfiguration.features & DOMConfigurationImpl.DTNORMALIZATION) != 0) {
          // datatype-normalization
          // NOTE: The specified value MUST be set after we set
          //       the node value because that turns the "specified"
          //       flag to "true" which may overwrite a "false"
          //       value from the attribute list.
          boolean specified = attr.getSpecified();
          attr.setValue(attrPSVI.getSchemaNormalizedValue());
          if (!specified) {
            ((AttrImpl) attr).setSpecified(specified);
          }
        }
      }
View Full Code Here

                attributes.getName(i, fAttrQName);
                Attr attr = createAttrNode(fAttrQName);

                String attrValue = attributes.getValue(i);

                AttributePSVI attrPSVI =(AttributePSVI) attributes.getAugmentations(i).getItem(Constants.ATTRIBUTE_PSVI);
          if (fStorePSVI && attrPSVI != null){
          ((PSVIAttrNSImpl) attr).setPSVI(attrPSVI);
                }
           
               
                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;
          Object type = null;
          boolean id = false;

          // REVISIT: currently it is possible that someone turns off
          // namespaces and turns on xml schema validation
          // To avoid classcast exception in AttrImpl check for namespaces
          // however the correct solution should probably disallow setting
          // namespaces to false when schema processing is turned on.
          if (attrPSVI != null && fNamespaceAware) {
            // XML Schema
            type = attrPSVI.getMemberTypeDefinition();
            if (type == null) {
              type = attrPSVI.getTypeDefinition();
              if (type != null) {
                id = ((XSSimpleType) type).isIDType();
                attrImpl.setType(type);
              }
            }
            else {
              id = ((XSSimpleType) type).isIDType();
              attrImpl.setType(type);
            }
          }
          else {
            // DTD
                        type = attributes.getType(i);
            attrImpl.setType(type);
            id = (type.equals("ID")) ? true : false;
          }
               
          if (id) {
            ((ElementImpl) el).setIdAttributeNode(attr, true);
          }

          attrImpl.setSpecified(attributes.isSpecified(i));
          // REVISIT: Handle entities in attribute value.
                }
            }
            setCharacterData(false);
           
            if (augs != null) {
                ElementPSVI elementPSVI = (ElementPSVI)augs.getItem(Constants.ELEMENT_PSVI);
                if (elementPSVI != null && fNamespaceAware) {
                    XSTypeDefinition type = elementPSVI.getMemberTypeDefinition();
                    if (type == null) {
                        type = elementPSVI.getTypeDefinition();
                    }
                    ((ElementNSImpl)el).setType(type);
                }
            }

           
            // 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 {
           Object type = null;
           if (augs != null) {
                ElementPSVI elementPSVI = (ElementPSVI)augs.getItem(Constants.ELEMENT_PSVI);
                if (elementPSVI != null) {
                    type = elementPSVI.getMemberTypeDefinition();
                    if (type == null) {
                        type = elementPSVI.getTypeDefinition();
                    }
                }
            }

            int el =
                fDeferredDocumentImpl.createDeferredElement(fNamespaceAware ?
                                                            element.uri : null,
                                                            element.rawname,
                                                            type);
            int attrCount = attributes.getLength();
            for (int i = 0; i < attrCount; i++) {
                // set type information
                AttributePSVI attrPSVI = (AttributePSVI)attributes.getAugmentations(i).getItem(Constants.ATTRIBUTE_PSVI);
                boolean id = false;

                // REVISIT: currently it is possible that someone turns off
                // namespaces and turns on xml schema validation
                // To avoid classcast exception in AttrImpl check for namespaces
                // however the correct solution should probably disallow setting
                // namespaces to false when schema processing is turned on.
        if (attrPSVI != null && fNamespaceAware) {
          // XML Schema
          type = attrPSVI.getMemberTypeDefinition();
          if (type == null) {
            type = attrPSVI.getTypeDefinition();
                        if (type != null){
              id = ((XSSimpleType) type).isIDType();
                        }
          }
          else {
View Full Code Here

                attributes.getName(i, fAttrQName);
                Attr attr = createAttrNode(fAttrQName);

                String attrValue = attributes.getValue(i);
                if (fStorePSVI) {
                    AttributePSVI attrPSVI = (AttributePSVI)attributes.getAugmentations(i).getItem(Constants.ATTRIBUTE_PSVI);
                    if (attrPSVI != null)
                        ((PSVIAttrNSImpl)attr).setPSVI(attrPSVI);
                }
               
                attr.setValue(attrValue);
View Full Code Here

                attributes.getName(i, fAttrQName);
                Attr attr = createAttrNode(fAttrQName);

                String attrValue = attributes.getValue(i);
                if (fStorePSVI) {
                    AttributePSVI attrPSVI = (AttributePSVI)attributes.getAugmentations(i).getItem(Constants.ATTRIBUTE_PSVI);
                    if (attrPSVI != null)
                        ((PSVIAttrNSImpl)attr).setPSVI(attrPSVI);
                }
               
                attr.setValue(attrValue);
View Full Code Here

        }
    }

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

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

            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");
            }

            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 = null;
                //REVISIT: schema elements must be namespace aware.
                //         DTD re-validation is not implemented yet..
                attr = currentElement.getAttributeNodeNS(fAttrQName.uri,fAttrQName.localpart);

                AttributePSVI attrPSVI = (AttributePSVI)attributes.getAugmentations(i).getItem(Constants.ATTRIBUTE_PSVI);
                if (attrPSVI !=null) {
                     ((PSVIAttrNSImpl)attr).setPSVI(attrPSVI);
                }
            }
        }
View Full Code Here

        }
    }

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

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

            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");
            }

            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

                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.VALIDATION_FULL) {
                            attributes.setValue(i, attrPSVI.getSchemaNormalizedValue());
                        }
                    }

                    if ((fQName.prefix != null && fQName.prefix.equals("xmlns")) ||
                        fQName.rawname.equals("xmlns")) {
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.