Java Code Examples for com.sun.org.apache.xerces.internal.xs.AttributePSVI#getTypeDefinition()

The following examples show how to use com.sun.org.apache.xerces.internal.xs.AttributePSVI#getTypeDefinition() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DOMResultAugmentor.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/** Returns whether the given attribute is an ID type. **/
private boolean processAttributePSVI(AttrImpl attr, AttributePSVI attrPSVI) {
    if (fStorePSVI) {
        ((PSVIAttrNSImpl) attr).setPSVI (attrPSVI);
    }
    Object type = attrPSVI.getMemberTypeDefinition ();
    if (type == null) {
        type = attrPSVI.getTypeDefinition ();
        if (type != null) {
            attr.setType(type);
            return ((XSSimpleType) type).isIDType();
        }
    }
    else {
        attr.setType(type);
        return ((XSSimpleType) type).isIDType();
    }
    return false;
}
 
Example 2
Source File: DOMResultAugmentor.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/** Returns whether the given attribute is an ID type. **/
private boolean processAttributePSVI(AttrImpl attr, AttributePSVI attrPSVI) {
    if (fStorePSVI) {
        ((PSVIAttrNSImpl) attr).setPSVI (attrPSVI);
    }
    Object type = attrPSVI.getMemberTypeDefinition ();
    if (type == null) {
        type = attrPSVI.getTypeDefinition ();
        if (type != null) {
            attr.setType(type);
            return ((XSSimpleType) type).isIDType();
        }
    }
    else {
        attr.setType(type);
        return ((XSSimpleType) type).isIDType();
    }
    return false;
}
 
Example 3
Source File: DOMResultAugmentor.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
/** Returns whether the given attribute is an ID type. **/
private boolean processAttributePSVI(AttrImpl attr, AttributePSVI attrPSVI) {
    if (fStorePSVI) {
        ((PSVIAttrNSImpl) attr).setPSVI (attrPSVI);
    }
    Object type = attrPSVI.getMemberTypeDefinition ();
    if (type == null) {
        type = attrPSVI.getTypeDefinition ();
        if (type != null) {
            attr.setType(type);
            return ((XSSimpleType) type).isIDType();
        }
    }
    else {
        attr.setType(type);
        return ((XSSimpleType) type).isIDType();
    }
    return false;
}
 
Example 4
Source File: DOMResultAugmentor.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/** Returns whether the given attribute is an ID type. **/
private boolean processAttributePSVI(AttrImpl attr, AttributePSVI attrPSVI) {
    if (fStorePSVI) {
        ((PSVIAttrNSImpl) attr).setPSVI (attrPSVI);
    }
    Object type = attrPSVI.getMemberTypeDefinition ();
    if (type == null) {
        type = attrPSVI.getTypeDefinition ();
        if (type != null) {
            attr.setType(type);
            return ((XSSimpleType) type).isIDType();
        }
    }
    else {
        attr.setType(type);
        return ((XSSimpleType) type).isIDType();
    }
    return false;
}
 
Example 5
Source File: DOMResultAugmentor.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/** Returns whether the given attribute is an ID type. **/
private boolean processAttributePSVI(AttrImpl attr, AttributePSVI attrPSVI) {
    if (fStorePSVI) {
        ((PSVIAttrNSImpl) attr).setPSVI (attrPSVI);
    }
    Object type = attrPSVI.getMemberTypeDefinition ();
    if (type == null) {
        type = attrPSVI.getTypeDefinition ();
        if (type != null) {
            attr.setType(type);
            return ((XSSimpleType) type).isIDType();
        }
    }
    else {
        attr.setType(type);
        return ((XSSimpleType) type).isIDType();
    }
    return false;
}
 
Example 6
Source File: PSVIAttrNSImpl.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
/**
 * Copy PSVI properties from another psvi item.
 *
 * @param attr  the source of attribute PSVI items
 */
public void setPSVI(AttributePSVI attr) {
    this.fDeclaration = attr.getAttributeDeclaration();
    this.fValidationContext = attr.getValidationContext();
    this.fValidity = attr.getValidity();
    this.fValidationAttempted = attr.getValidationAttempted();
    this.fErrorCodes = attr.getErrorCodes();
    this.fNormalizedValue = attr.getSchemaNormalizedValue();
    this.fActualValue = attr.getActualNormalizedValue();
    this.fActualValueType = attr.getActualNormalizedValueType();
    this.fItemValueTypes = attr.getItemValueTypes();
    this.fTypeDecl = attr.getTypeDefinition();
    this.fMemberType = attr.getMemberTypeDefinition();
    this.fSpecified = attr.getIsSchemaSpecified();
}
 
Example 7
Source File: ShortHandPointer.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns the schema-determined-ID.
 *
 *
 * @param attributes
 * @param index
 * @return A String containing the schema-determined ID.
 * @throws XNIException
 */
public String getSchemaDeterminedID(XMLAttributes attributes, int index)
throws XNIException {
    Augmentations augs = attributes.getAugmentations(index);
    AttributePSVI attrPSVI = (AttributePSVI) augs
    .getItem(Constants.ATTRIBUTE_PSVI);

    if (attrPSVI != null) {
        // An element or attribute information item is a schema-determined
        // ID if and only if one of the following is true:]

        // 1. It has a [member type definition] or [type definition] property
        // whose value in turn has [name] equal to ID and [target namespace]
        // equal to http://www.w3.org/2001/XMLSchema;

        // 2. It has a [base type definition] whose value has that [name] and [target namespace];

        // 3. It has a [base type definition] whose value has a [base type definition]
        // whose value has that [name] and [target namespace], and so on following
        // the [base type definition] property recursively;

        XSTypeDefinition typeDef = attrPSVI.getMemberTypeDefinition();
        if (typeDef != null) {
            typeDef = attrPSVI.getTypeDefinition();
        }

        //
        if (typeDef != null && ((XSSimpleType) typeDef).isIDType()) {
            return attrPSVI.getSchemaNormalizedValue();
        }

        // 4 & 5 NA
    }

    return null;
}
 
Example 8
Source File: PSVIAttrNSImpl.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Copy PSVI properties from another psvi item.
 *
 * @param attr  the source of attribute PSVI items
 */
public void setPSVI(AttributePSVI attr) {
    this.fDeclaration = attr.getAttributeDeclaration();
    this.fValidationContext = attr.getValidationContext();
    this.fValidity = attr.getValidity();
    this.fValidationAttempted = attr.getValidationAttempted();
    this.fErrorCodes = attr.getErrorCodes();
    this.fNormalizedValue = attr.getSchemaNormalizedValue();
    this.fActualValue = attr.getActualNormalizedValue();
    this.fActualValueType = attr.getActualNormalizedValueType();
    this.fItemValueTypes = attr.getItemValueTypes();
    this.fTypeDecl = attr.getTypeDefinition();
    this.fMemberType = attr.getMemberTypeDefinition();
    this.fSpecified = attr.getIsSchemaSpecified();
}
 
Example 9
Source File: ShortHandPointer.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns the schema-determined-ID.
 *
 *
 * @param attributes
 * @param index
 * @return A String containing the schema-determined ID.
 * @throws XNIException
 */
public String getSchemaDeterminedID(XMLAttributes attributes, int index)
throws XNIException {
    Augmentations augs = attributes.getAugmentations(index);
    AttributePSVI attrPSVI = (AttributePSVI) augs
    .getItem(Constants.ATTRIBUTE_PSVI);

    if (attrPSVI != null) {
        // An element or attribute information item is a schema-determined
        // ID if and only if one of the following is true:]

        // 1. It has a [member type definition] or [type definition] property
        // whose value in turn has [name] equal to ID and [target namespace]
        // equal to http://www.w3.org/2001/XMLSchema;

        // 2. It has a [base type definition] whose value has that [name] and [target namespace];

        // 3. It has a [base type definition] whose value has a [base type definition]
        // whose value has that [name] and [target namespace], and so on following
        // the [base type definition] property recursively;

        XSTypeDefinition typeDef = attrPSVI.getMemberTypeDefinition();
        if (typeDef != null) {
            typeDef = attrPSVI.getTypeDefinition();
        }

        //
        if (typeDef != null && ((XSSimpleType) typeDef).isIDType()) {
            return attrPSVI.getSchemaNormalizedValue();
        }

        // 4 & 5 NA
    }

    return null;
}
 
Example 10
Source File: PSVIAttrNSImpl.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Copy PSVI properties from another psvi item.
 *
 * @param attr  the source of attribute PSVI items
 */
public void setPSVI(AttributePSVI attr) {
    this.fDeclaration = attr.getAttributeDeclaration();
    this.fValidationContext = attr.getValidationContext();
    this.fValidity = attr.getValidity();
    this.fValidationAttempted = attr.getValidationAttempted();
    this.fErrorCodes = attr.getErrorCodes();
    this.fNormalizedValue = attr.getSchemaNormalizedValue();
    this.fActualValue = attr.getActualNormalizedValue();
    this.fActualValueType = attr.getActualNormalizedValueType();
    this.fItemValueTypes = attr.getItemValueTypes();
    this.fTypeDecl = attr.getTypeDefinition();
    this.fMemberType = attr.getMemberTypeDefinition();
    this.fSpecified = attr.getIsSchemaSpecified();
}
 
Example 11
Source File: PSVIAttrNSImpl.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Copy PSVI properties from another psvi item.
 *
 * @param attr  the source of attribute PSVI items
 */
public void setPSVI(AttributePSVI attr) {
    this.fDeclaration = attr.getAttributeDeclaration();
    this.fValidationContext = attr.getValidationContext();
    this.fValidity = attr.getValidity();
    this.fValidationAttempted = attr.getValidationAttempted();
    this.fErrorCodes = attr.getErrorCodes();
    this.fNormalizedValue = attr.getSchemaNormalizedValue();
    this.fActualValue = attr.getActualNormalizedValue();
    this.fActualValueType = attr.getActualNormalizedValueType();
    this.fItemValueTypes = attr.getItemValueTypes();
    this.fTypeDecl = attr.getTypeDefinition();
    this.fMemberType = attr.getMemberTypeDefinition();
    this.fSpecified = attr.getIsSchemaSpecified();
}
 
Example 12
Source File: ShortHandPointer.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns the schema-determined-ID.
 *
 *
 * @param attributes
 * @param index
 * @return A String containing the schema-determined ID.
 * @throws XNIException
 */
public String getSchemaDeterminedID(XMLAttributes attributes, int index)
throws XNIException {
    Augmentations augs = attributes.getAugmentations(index);
    AttributePSVI attrPSVI = (AttributePSVI) augs
    .getItem(Constants.ATTRIBUTE_PSVI);

    if (attrPSVI != null) {
        // An element or attribute information item is a schema-determined
        // ID if and only if one of the following is true:]

        // 1. It has a [member type definition] or [type definition] property
        // whose value in turn has [name] equal to ID and [target namespace]
        // equal to http://www.w3.org/2001/XMLSchema;

        // 2. It has a [base type definition] whose value has that [name] and [target namespace];

        // 3. It has a [base type definition] whose value has a [base type definition]
        // whose value has that [name] and [target namespace], and so on following
        // the [base type definition] property recursively;

        XSTypeDefinition typeDef = attrPSVI.getMemberTypeDefinition();
        if (typeDef != null) {
            typeDef = attrPSVI.getTypeDefinition();
        }

        //
        if (typeDef != null && ((XSSimpleType) typeDef).isIDType()) {
            return attrPSVI.getSchemaNormalizedValue();
        }

        // 4 & 5 NA
    }

    return null;
}
 
Example 13
Source File: ShortHandPointer.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
/**
 * Returns the schema-determined-ID.
 *
 *
 * @param attributes
 * @param index
 * @return A String containing the schema-determined ID.
 * @throws XNIException
 */
public String getSchemaDeterminedID(XMLAttributes attributes, int index)
throws XNIException {
    Augmentations augs = attributes.getAugmentations(index);
    AttributePSVI attrPSVI = (AttributePSVI) augs
    .getItem(Constants.ATTRIBUTE_PSVI);

    if (attrPSVI != null) {
        // An element or attribute information item is a schema-determined
        // ID if and only if one of the following is true:]

        // 1. It has a [member type definition] or [type definition] property
        // whose value in turn has [name] equal to ID and [target namespace]
        // equal to http://www.w3.org/2001/XMLSchema;

        // 2. It has a [base type definition] whose value has that [name] and [target namespace];

        // 3. It has a [base type definition] whose value has a [base type definition]
        // whose value has that [name] and [target namespace], and so on following
        // the [base type definition] property recursively;

        XSTypeDefinition typeDef = attrPSVI.getMemberTypeDefinition();
        if (typeDef != null) {
            typeDef = attrPSVI.getTypeDefinition();
        }

        //
        if (typeDef != null && ((XSSimpleType) typeDef).isIDType()) {
            return attrPSVI.getSchemaNormalizedValue();
        }

        // 4 & 5 NA
    }

    return null;
}
 
Example 14
Source File: DOMNormalizer.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
/**
* The start of an element.
*
* @param element    The name of the element.
* @param attributes The element attributes.
* @param augs       Additional information that may include infoset augmentations
*
* @exception XNIException
*                   Thrown by handler to signal an error.
*/
   public void startElement(QName element, XMLAttributes attributes, Augmentations augs)
           throws XNIException {
           Element currentElement = (Element) fCurrentNode;
           int attrCount = attributes.getLength();
   if (DEBUG_EVENTS) {
       System.out.println("==>startElement: " +element+
       " attrs.length="+attrCount);
   }

           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);
                                   }
                           }
                   }
           }
   }
 
Example 15
Source File: DOMNormalizer.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
* The start of an element.
*
* @param element    The name of the element.
* @param attributes The element attributes.
* @param augs       Additional information that may include infoset augmentations
*
* @exception XNIException
*                   Thrown by handler to signal an error.
*/
   public void startElement(QName element, XMLAttributes attributes, Augmentations augs)
           throws XNIException {
           Element currentElement = (Element) fCurrentNode;
           int attrCount = attributes.getLength();
   if (DEBUG_EVENTS) {
       System.out.println("==>startElement: " +element+
       " attrs.length="+attrCount);
   }

           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);
                                   }
                           }
                   }
           }
   }
 
Example 16
Source File: DOMResultBuilder.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
public void startElement(QName element, XMLAttributes attributes,
        Augmentations augs) throws XNIException {
    Element elem;
    int attrCount = attributes.getLength();
    if (fDocumentImpl == null) {
        elem = fDocument.createElementNS(element.uri, element.rawname);
        for (int i = 0; i < attrCount; ++i) {
            attributes.getName(i, fAttributeQName);
            elem.setAttributeNS(fAttributeQName.uri, fAttributeQName.rawname, attributes.getValue(i));
        }
    }
    // If it's a Xerces DOM store type information for attributes, set idness, etc..
    else {
        elem = fDocumentImpl.createElementNS(element.uri, element.rawname, element.localpart);
        for (int i = 0; i < attrCount; ++i) {
            attributes.getName(i, fAttributeQName);
            AttrImpl attr = (AttrImpl) fDocumentImpl.createAttributeNS(fAttributeQName.uri,
                    fAttributeQName.rawname, fAttributeQName.localpart);
            attr.setValue(attributes.getValue(i));

            // write type information to this attribute
            AttributePSVI attrPSVI = (AttributePSVI) attributes.getAugmentations(i).getItem (Constants.ATTRIBUTE_PSVI);
            if (attrPSVI != null) {
                if (fStorePSVI) {
                    ((PSVIAttrNSImpl) attr).setPSVI(attrPSVI);
                }
                Object type = attrPSVI.getMemberTypeDefinition();
                if (type == null) {
                    type = attrPSVI.getTypeDefinition();
                    if (type != null) {
                        attr.setType (type);
                        if (((XSSimpleType) type).isIDType()) {
                            ((ElementImpl) elem).setIdAttributeNode (attr, true);
                        }
                    }
                }
                else {
                    attr.setType (type);
                    if (((XSSimpleType) type).isIDType()) {
                        ((ElementImpl) elem).setIdAttributeNode (attr, true);
                    }
                }
            }
            attr.setSpecified(attributes.isSpecified(i));
            elem.setAttributeNode(attr);
        }
    }
    append(elem);
    fCurrentNode = elem;
    if (fFragmentRoot == null) {
        fFragmentRoot = elem;
    }
}
 
Example 17
Source File: DOMResultBuilder.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
public void startElement(QName element, XMLAttributes attributes,
        Augmentations augs) throws XNIException {
    Element elem;
    int attrCount = attributes.getLength();
    if (fDocumentImpl == null) {
        elem = fDocument.createElementNS(element.uri, element.rawname);
        for (int i = 0; i < attrCount; ++i) {
            attributes.getName(i, fAttributeQName);
            elem.setAttributeNS(fAttributeQName.uri, fAttributeQName.rawname, attributes.getValue(i));
        }
    }
    // If it's a Xerces DOM store type information for attributes, set idness, etc..
    else {
        elem = fDocumentImpl.createElementNS(element.uri, element.rawname, element.localpart);
        for (int i = 0; i < attrCount; ++i) {
            attributes.getName(i, fAttributeQName);
            AttrImpl attr = (AttrImpl) fDocumentImpl.createAttributeNS(fAttributeQName.uri,
                    fAttributeQName.rawname, fAttributeQName.localpart);
            attr.setValue(attributes.getValue(i));

            // write type information to this attribute
            AttributePSVI attrPSVI = (AttributePSVI) attributes.getAugmentations(i).getItem (Constants.ATTRIBUTE_PSVI);
            if (attrPSVI != null) {
                if (fStorePSVI) {
                    ((PSVIAttrNSImpl) attr).setPSVI(attrPSVI);
                }
                Object type = attrPSVI.getMemberTypeDefinition();
                if (type == null) {
                    type = attrPSVI.getTypeDefinition();
                    if (type != null) {
                        attr.setType (type);
                        if (((XSSimpleType) type).isIDType()) {
                            ((ElementImpl) elem).setIdAttributeNode (attr, true);
                        }
                    }
                }
                else {
                    attr.setType (type);
                    if (((XSSimpleType) type).isIDType()) {
                        ((ElementImpl) elem).setIdAttributeNode (attr, true);
                    }
                }
            }
            attr.setSpecified(attributes.isSpecified(i));
            elem.setAttributeNode(attr);
        }
    }
    append(elem);
    fCurrentNode = elem;
    if (fFragmentRoot == null) {
        fFragmentRoot = elem;
    }
}
 
Example 18
Source File: DOMNormalizer.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
* The start of an element.
*
* @param element    The name of the element.
* @param attributes The element attributes.
* @param augs       Additional information that may include infoset augmentations
*
* @exception XNIException
*                   Thrown by handler to signal an error.
*/
   public void startElement(QName element, XMLAttributes attributes, Augmentations augs)
           throws XNIException {
           Element currentElement = (Element) fCurrentNode;
           int attrCount = attributes.getLength();
   if (DEBUG_EVENTS) {
       System.out.println("==>startElement: " +element+
       " attrs.length="+attrCount);
   }

           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);
                                   }
                           }
                   }
           }
   }
 
Example 19
Source File: DOMResultBuilder.java    From jdk1.8-source-analysis with Apache License 2.0 4 votes vote down vote up
public void startElement(QName element, XMLAttributes attributes,
        Augmentations augs) throws XNIException {
    Element elem;
    int attrCount = attributes.getLength();
    if (fDocumentImpl == null) {
        elem = fDocument.createElementNS(element.uri, element.rawname);
        for (int i = 0; i < attrCount; ++i) {
            attributes.getName(i, fAttributeQName);
            elem.setAttributeNS(fAttributeQName.uri, fAttributeQName.rawname, attributes.getValue(i));
        }
    }
    // If it's a Xerces DOM store type information for attributes, set idness, etc..
    else {
        elem = fDocumentImpl.createElementNS(element.uri, element.rawname, element.localpart);
        for (int i = 0; i < attrCount; ++i) {
            attributes.getName(i, fAttributeQName);
            AttrImpl attr = (AttrImpl) fDocumentImpl.createAttributeNS(fAttributeQName.uri,
                    fAttributeQName.rawname, fAttributeQName.localpart);
            attr.setValue(attributes.getValue(i));

            // write type information to this attribute
            AttributePSVI attrPSVI = (AttributePSVI) attributes.getAugmentations(i).getItem (Constants.ATTRIBUTE_PSVI);
            if (attrPSVI != null) {
                if (fStorePSVI) {
                    ((PSVIAttrNSImpl) attr).setPSVI(attrPSVI);
                }
                Object type = attrPSVI.getMemberTypeDefinition();
                if (type == null) {
                    type = attrPSVI.getTypeDefinition();
                    if (type != null) {
                        attr.setType (type);
                        if (((XSSimpleType) type).isIDType()) {
                            ((ElementImpl) elem).setIdAttributeNode (attr, true);
                        }
                    }
                }
                else {
                    attr.setType (type);
                    if (((XSSimpleType) type).isIDType()) {
                        ((ElementImpl) elem).setIdAttributeNode (attr, true);
                    }
                }
            }
            attr.setSpecified(attributes.isSpecified(i));
            elem.setAttributeNode(attr);
        }
    }
    append(elem);
    fCurrentNode = elem;
    if (fFragmentRoot == null) {
        fFragmentRoot = elem;
    }
}
 
Example 20
Source File: DOMResultBuilder.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
public void startElement(QName element, XMLAttributes attributes,
        Augmentations augs) throws XNIException {
    Element elem;
    int attrCount = attributes.getLength();
    if (fDocumentImpl == null) {
        elem = fDocument.createElementNS(element.uri, element.rawname);
        for (int i = 0; i < attrCount; ++i) {
            attributes.getName(i, fAttributeQName);
            elem.setAttributeNS(fAttributeQName.uri, fAttributeQName.rawname, attributes.getValue(i));
        }
    }
    // If it's a Xerces DOM store type information for attributes, set idness, etc..
    else {
        elem = fDocumentImpl.createElementNS(element.uri, element.rawname, element.localpart);
        for (int i = 0; i < attrCount; ++i) {
            attributes.getName(i, fAttributeQName);
            AttrImpl attr = (AttrImpl) fDocumentImpl.createAttributeNS(fAttributeQName.uri,
                    fAttributeQName.rawname, fAttributeQName.localpart);
            attr.setValue(attributes.getValue(i));

            // write type information to this attribute
            AttributePSVI attrPSVI = (AttributePSVI) attributes.getAugmentations(i).getItem (Constants.ATTRIBUTE_PSVI);
            if (attrPSVI != null) {
                if (fStorePSVI) {
                    ((PSVIAttrNSImpl) attr).setPSVI(attrPSVI);
                }
                Object type = attrPSVI.getMemberTypeDefinition();
                if (type == null) {
                    type = attrPSVI.getTypeDefinition();
                    if (type != null) {
                        attr.setType (type);
                        if (((XSSimpleType) type).isIDType()) {
                            ((ElementImpl) elem).setIdAttributeNode (attr, true);
                        }
                    }
                }
                else {
                    attr.setType (type);
                    if (((XSSimpleType) type).isIDType()) {
                        ((ElementImpl) elem).setIdAttributeNode (attr, true);
                    }
                }
            }
            attr.setSpecified(attributes.isSpecified(i));
            elem.setAttributeNode(attr);
        }
    }
    append(elem);
    fCurrentNode = elem;
    if (fFragmentRoot == null) {
        fFragmentRoot = elem;
    }
}