Java Code Examples for com.sun.org.apache.xerces.internal.xni.XMLAttributes#setValue()

The following examples show how to use com.sun.org.apache.xerces.internal.xni.XMLAttributes#setValue() . 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: XMLDTDValidator.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Normalize the attribute value of a non CDATA attributes collapsing
 * sequences of space characters (x20)
 *
 * @param attributes The list of attributes
 * @param index The index of the attribute to normalize
 */
private boolean normalizeAttrValue(XMLAttributes attributes, int index) {
    // vars
    boolean leadingSpace = true;
    boolean spaceStart = false;
    boolean readingNonSpace = false;
    int count = 0;
    int eaten = 0;
    String attrValue = attributes.getValue(index);
    char[] attValue = new char[attrValue.length()];

    fBuffer.setLength(0);
    attrValue.getChars(0, attrValue.length(), attValue, 0);
    for (int i = 0; i < attValue.length; i++) {

        if (attValue[i] == ' ') {

            // now the tricky part
            if (readingNonSpace) {
                spaceStart = true;
                readingNonSpace = false;
            }

            if (spaceStart && !leadingSpace) {
                spaceStart = false;
                fBuffer.append(attValue[i]);
                count++;
            }
            else {
                if (leadingSpace || !spaceStart) {
                    eaten ++;
                    /*** BUG #3512 ***
                    int entityCount = attributes.getEntityCount(index);
                    for (int j = 0;  j < entityCount; j++) {
                        int offset = attributes.getEntityOffset(index, j);
                        int length = attributes.getEntityLength(index, j);
                        if (offset <= i-eaten+1) {
                            if (offset+length >= i-eaten+1) {
                                if (length > 0)
                                    length--;
                            }
                        }
                        else {
                            if (offset > 0)
                                offset--;
                        }
                        attributes.setEntityOffset(index, j, offset);
                        attributes.setEntityLength(index, j, length);
                    }
                    /***/
                }
            }

        }
        else {
            readingNonSpace = true;
            spaceStart = false;
            leadingSpace = false;
            fBuffer.append(attValue[i]);
            count++;
        }
    }

    // check if the last appended character is a space.
    if (count > 0 && fBuffer.charAt(count-1) == ' ') {
        fBuffer.setLength(count-1);
        /*** BUG #3512 ***
        int entityCount = attributes.getEntityCount(index);
        for (int j=0;  j < entityCount; j++) {
            int offset = attributes.getEntityOffset(index, j);
            int length = attributes.getEntityLength(index, j);
            if (offset < count-1) {
                if (offset+length == count) {
                    length--;
                }
            }
            else {
                offset--;
            }
            attributes.setEntityOffset(index, j, offset);
            attributes.setEntityLength(index, j, length);
        }
        /***/
    }
    String newValue = fBuffer.toString();
    attributes.setValue(index, newValue);
    return ! attrValue.equals(newValue);
}
 
Example 2
Source File: DTDGrammarUtil.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Normalize the attribute value of a non CDATA attributes collapsing
 * sequences of space characters (x20)
 *
 * @param attributes The list of attributes
 * @param index The index of the attribute to normalize
 */
private boolean normalizeAttrValue(XMLAttributes attributes, int index) {
    // vars
    boolean leadingSpace = true;
    boolean spaceStart = false;
    boolean readingNonSpace = false;
    int count = 0;
    int eaten = 0;
    String attrValue = attributes.getValue(index);
    char[] attValue = new char[attrValue.length()];

    fBuffer.setLength(0);
    attrValue.getChars(0, attrValue.length(), attValue, 0);
    for (int i = 0; i < attValue.length; i++) {

        if (attValue[i] == ' ') {

            // now the tricky part
            if (readingNonSpace) {
                spaceStart = true;
                readingNonSpace = false;
            }

            if (spaceStart && !leadingSpace) {
                spaceStart = false;
                fBuffer.append(attValue[i]);
                count++;
            } else {
                if (leadingSpace || !spaceStart) {
                    eaten++;
                }
            }

        } else {
            readingNonSpace = true;
            spaceStart = false;
            leadingSpace = false;
            fBuffer.append(attValue[i]);
            count++;
        }
    }

    // check if the last appended character is a space.
    if (count > 0 && fBuffer.charAt(count - 1) == ' ') {
        fBuffer.setLength(count - 1);

    }
    String newValue = fBuffer.toString();
    attributes.setValue(index, newValue);
    return !attrValue.equals(newValue);
}
 
Example 3
Source File: XMLDocumentFragmentScannerImpl.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Scans an attribute name value pair.
 * <p>
 * <pre>
 * [41] Attribute ::= Name Eq AttValue
 * </pre>
 * <p>
 * <strong>Note:</strong> This method assumes that the next
 * character on the stream is the first character of the attribute
 * name.
 * <p>
 * <strong>Note:</strong> This method uses the fAttributeQName and
 * fQName variables. The contents of these variables will be
 * destroyed.
 *
 * @param attributes The attributes list for the scanned attribute.
 */

protected void scanAttribute(XMLAttributes attributes)
throws IOException, XNIException {
    if (DEBUG_START_END_ELEMENT) System.out.println(this.getClass().toString() +">>> scanAttribute()");

    // name
    if (fNamespaces) {
        fEntityScanner.scanQName(fAttributeQName);
    } else {
        String name = fEntityScanner.scanName();
        fAttributeQName.setValues(null, name, name, null);
    }

    // equals
    fEntityScanner.skipSpaces();
    if (!fEntityScanner.skipChar('=')) {
        reportFatalError("EqRequiredInAttribute",
            new Object[] {fCurrentElement.rawname, fAttributeQName.rawname});
    }
    fEntityScanner.skipSpaces();

    int attIndex = 0 ;
    //REVISIT: one more case needs to be included: external PE and standalone is no
    boolean isVC =  fHasExternalDTD && !fStandalone;
    //fTempString would store attribute value
    ///fTempString2 would store attribute non-normalized value

    //this function doesn't use 'attIndex'. We are adding the attribute later
    //after we have figured out that current attribute is not namespace declaration
    //since scanAttributeValue doesn't use attIndex parameter therefore we
    //can safely add the attribute later..
    XMLString tmpStr = getString();

    scanAttributeValue(tmpStr, fTempString2,
            fAttributeQName.rawname, attributes,
            attIndex, isVC, fCurrentElement.rawname);

    // content
    int oldLen = attributes.getLength();
    //if the attribute name already exists.. new value is replaced with old value
    attIndex = attributes.addAttribute(fAttributeQName, XMLSymbols.fCDATASymbol, null);

    // WFC: Unique Att Spec
    //attributes count will be same if the current attribute  name already exists for this element name.
    //this means there are two duplicate attributes.
    if (oldLen == attributes.getLength()) {
        reportFatalError("AttributeNotUnique",
                new Object[]{fCurrentElement.rawname,
                        fAttributeQName.rawname});
    }

    //tmpString contains attribute value
    //we are passing null as the attribute value
    attributes.setValue(attIndex, null, tmpStr);

    ///xxx: nonNormalizedValue is not being set as it is not required by SAX & DOM
    //attributes.setNonNormalizedValue(oldLen, fTempString2.toString());
    attributes.setSpecified(attIndex, true);

    if (DEBUG_START_END_ELEMENT) System.out.println(this.getClass().toString() +"<<< scanAttribute()");

}
 
Example 4
Source File: XMLDocumentFragmentScannerImpl.java    From Bytecoder with Apache License 2.0 4 votes vote down vote up
/**
 * Scans an attribute name value pair.
 * <p>
 * <pre>
 * [41] Attribute ::= Name Eq AttValue
 * </pre>
 * <p>
 * <strong>Note:</strong> This method assumes that the next
 * character on the stream is the first character of the attribute
 * name.
 * <p>
 * <strong>Note:</strong> This method uses the fAttributeQName and
 * fQName variables. The contents of these variables will be
 * destroyed.
 *
 * @param attributes The attributes list for the scanned attribute.
 */

protected void scanAttribute(XMLAttributes attributes)
throws IOException, XNIException {
    if (DEBUG_START_END_ELEMENT) System.out.println(this.getClass().toString() +">>> scanAttribute()");

    // name
    if (fNamespaces) {
        fEntityScanner.scanQName(fAttributeQName, NameType.ATTRIBUTENAME);
    } else {
        String name = fEntityScanner.scanName(NameType.ATTRIBUTENAME);
        fAttributeQName.setValues(null, name, name, null);
    }

    // equals
    fEntityScanner.skipSpaces();
    if (!fEntityScanner.skipChar('=', NameType.ATTRIBUTE)) {
        reportFatalError("EqRequiredInAttribute",
            new Object[] {fCurrentElement.rawname, fAttributeQName.rawname});
    }
    fEntityScanner.skipSpaces();

    int attIndex = 0 ;
    //REVISIT: one more case needs to be included: external PE and standalone is no
    boolean isVC =  fHasExternalDTD && !fStandalone;
    //fTempString would store attribute value
    ///fTempString2 would store attribute non-normalized value

    //this function doesn't use 'attIndex'. We are adding the attribute later
    //after we have figured out that current attribute is not namespace declaration
    //since scanAttributeValue doesn't use attIndex parameter therefore we
    //can safely add the attribute later..
    XMLString tmpStr = getString();

    scanAttributeValue(tmpStr, fTempString2, fAttributeQName.rawname, attributes,
            attIndex, isVC, fCurrentElement.rawname, false);

    // content
    int oldLen = attributes.getLength();
    //if the attribute name already exists.. new value is replaced with old value
    attIndex = attributes.addAttribute(fAttributeQName, XMLSymbols.fCDATASymbol, null);

    // WFC: Unique Att Spec
    //attributes count will be same if the current attribute  name already exists for this element name.
    //this means there are two duplicate attributes.
    if (oldLen == attributes.getLength()) {
        reportFatalError("AttributeNotUnique",
                new Object[]{fCurrentElement.rawname,
                        fAttributeQName.rawname});
    }

    //tmpString contains attribute value
    //we are passing null as the attribute value
    attributes.setValue(attIndex, null, tmpStr);

    ///xxx: nonNormalizedValue is not being set as it is not required by SAX & DOM
    //attributes.setNonNormalizedValue(oldLen, fTempString2.toString());
    attributes.setSpecified(attIndex, true);

    if (DEBUG_START_END_ELEMENT) System.out.println(this.getClass().toString() +"<<< scanAttribute()");

}
 
Example 5
Source File: DTDGrammarUtil.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Normalize the attribute value of a non CDATA attributes collapsing
 * sequences of space characters (x20)
 *
 * @param attributes The list of attributes
 * @param index The index of the attribute to normalize
 */
private boolean normalizeAttrValue(XMLAttributes attributes, int index) {
    // vars
    boolean leadingSpace = true;
    boolean spaceStart = false;
    boolean readingNonSpace = false;
    int count = 0;
    int eaten = 0;
    String attrValue = attributes.getValue(index);
    char[] attValue = new char[attrValue.length()];

    fBuffer.setLength(0);
    attrValue.getChars(0, attrValue.length(), attValue, 0);
    for (int i = 0; i < attValue.length; i++) {

        if (attValue[i] == ' ') {

            // now the tricky part
            if (readingNonSpace) {
                spaceStart = true;
                readingNonSpace = false;
            }

            if (spaceStart && !leadingSpace) {
                spaceStart = false;
                fBuffer.append(attValue[i]);
                count++;
            } else {
                if (leadingSpace || !spaceStart) {
                    eaten++;
                }
            }

        } else {
            readingNonSpace = true;
            spaceStart = false;
            leadingSpace = false;
            fBuffer.append(attValue[i]);
            count++;
        }
    }

    // check if the last appended character is a space.
    if (count > 0 && fBuffer.charAt(count - 1) == ' ') {
        fBuffer.setLength(count - 1);

    }
    String newValue = fBuffer.toString();
    attributes.setValue(index, newValue);
    return !attrValue.equals(newValue);
}
 
Example 6
Source File: DTDGrammarUtil.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Normalize the attribute value of a non CDATA attributes collapsing
 * sequences of space characters (x20)
 *
 * @param attributes The list of attributes
 * @param index The index of the attribute to normalize
 */
private boolean normalizeAttrValue(XMLAttributes attributes, int index) {
    // vars
    boolean leadingSpace = true;
    boolean spaceStart = false;
    boolean readingNonSpace = false;
    int count = 0;
    int eaten = 0;
    String attrValue = attributes.getValue(index);
    char[] attValue = new char[attrValue.length()];

    fBuffer.setLength(0);
    attrValue.getChars(0, attrValue.length(), attValue, 0);
    for (int i = 0; i < attValue.length; i++) {

        if (attValue[i] == ' ') {

            // now the tricky part
            if (readingNonSpace) {
                spaceStart = true;
                readingNonSpace = false;
            }

            if (spaceStart && !leadingSpace) {
                spaceStart = false;
                fBuffer.append(attValue[i]);
                count++;
            } else {
                if (leadingSpace || !spaceStart) {
                    eaten++;
                }
            }

        } else {
            readingNonSpace = true;
            spaceStart = false;
            leadingSpace = false;
            fBuffer.append(attValue[i]);
            count++;
        }
    }

    // check if the last appended character is a space.
    if (count > 0 && fBuffer.charAt(count - 1) == ' ') {
        fBuffer.setLength(count - 1);

    }
    String newValue = fBuffer.toString();
    attributes.setValue(index, newValue);
    return !attrValue.equals(newValue);
}
 
Example 7
Source File: XMLDocumentFragmentScannerImpl.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Scans an attribute name value pair.
 * <p>
 * <pre>
 * [41] Attribute ::= Name Eq AttValue
 * </pre>
 * <p>
 * <strong>Note:</strong> This method assumes that the next
 * character on the stream is the first character of the attribute
 * name.
 * <p>
 * <strong>Note:</strong> This method uses the fAttributeQName and
 * fQName variables. The contents of these variables will be
 * destroyed.
 *
 * @param attributes The attributes list for the scanned attribute.
 */

protected void scanAttribute(XMLAttributes attributes)
throws IOException, XNIException {
    if (DEBUG_START_END_ELEMENT) System.out.println(this.getClass().toString() +">>> scanAttribute()");

    // name
    if (fNamespaces) {
        fEntityScanner.scanQName(fAttributeQName, NameType.ATTRIBUTENAME);
    } else {
        String name = fEntityScanner.scanName(NameType.ATTRIBUTENAME);
        fAttributeQName.setValues(null, name, name, null);
    }

    // equals
    fEntityScanner.skipSpaces();
    if (!fEntityScanner.skipChar('=', NameType.ATTRIBUTE)) {
        reportFatalError("EqRequiredInAttribute",
            new Object[] {fCurrentElement.rawname, fAttributeQName.rawname});
    }
    fEntityScanner.skipSpaces();

    int attIndex = 0 ;
    //REVISIT: one more case needs to be included: external PE and standalone is no
    boolean isVC =  fHasExternalDTD && !fStandalone;
    //fTempString would store attribute value
    ///fTempString2 would store attribute non-normalized value

    //this function doesn't use 'attIndex'. We are adding the attribute later
    //after we have figured out that current attribute is not namespace declaration
    //since scanAttributeValue doesn't use attIndex parameter therefore we
    //can safely add the attribute later..
    XMLString tmpStr = getString();

    scanAttributeValue(tmpStr, fTempString2, fAttributeQName.rawname, attributes,
            attIndex, isVC, fCurrentElement.rawname, false);

    // content
    int oldLen = attributes.getLength();
    //if the attribute name already exists.. new value is replaced with old value
    attIndex = attributes.addAttribute(fAttributeQName, XMLSymbols.fCDATASymbol, null);

    // WFC: Unique Att Spec
    //attributes count will be same if the current attribute  name already exists for this element name.
    //this means there are two duplicate attributes.
    if (oldLen == attributes.getLength()) {
        reportFatalError("AttributeNotUnique",
                new Object[]{fCurrentElement.rawname,
                        fAttributeQName.rawname});
    }

    //tmpString contains attribute value
    //we are passing null as the attribute value
    attributes.setValue(attIndex, null, tmpStr);

    ///xxx: nonNormalizedValue is not being set as it is not required by SAX & DOM
    //attributes.setNonNormalizedValue(oldLen, fTempString2.toString());
    attributes.setSpecified(attIndex, true);

    if (DEBUG_START_END_ELEMENT) System.out.println(this.getClass().toString() +"<<< scanAttribute()");

}
 
Example 8
Source File: XMLDTDValidator.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Normalize the attribute value of a non CDATA attributes collapsing
 * sequences of space characters (x20)
 *
 * @param attributes The list of attributes
 * @param index The index of the attribute to normalize
 */
private boolean normalizeAttrValue(XMLAttributes attributes, int index) {
    // vars
    boolean leadingSpace = true;
    boolean spaceStart = false;
    boolean readingNonSpace = false;
    int count = 0;
    int eaten = 0;
    String attrValue = attributes.getValue(index);
    char[] attValue = new char[attrValue.length()];

    fBuffer.setLength(0);
    attrValue.getChars(0, attrValue.length(), attValue, 0);
    for (int i = 0; i < attValue.length; i++) {

        if (attValue[i] == ' ') {

            // now the tricky part
            if (readingNonSpace) {
                spaceStart = true;
                readingNonSpace = false;
            }

            if (spaceStart && !leadingSpace) {
                spaceStart = false;
                fBuffer.append(attValue[i]);
                count++;
            }
            else {
                if (leadingSpace || !spaceStart) {
                    eaten ++;
                    /*** BUG #3512 ***
                    int entityCount = attributes.getEntityCount(index);
                    for (int j = 0;  j < entityCount; j++) {
                        int offset = attributes.getEntityOffset(index, j);
                        int length = attributes.getEntityLength(index, j);
                        if (offset <= i-eaten+1) {
                            if (offset+length >= i-eaten+1) {
                                if (length > 0)
                                    length--;
                            }
                        }
                        else {
                            if (offset > 0)
                                offset--;
                        }
                        attributes.setEntityOffset(index, j, offset);
                        attributes.setEntityLength(index, j, length);
                    }
                    /***/
                }
            }

        }
        else {
            readingNonSpace = true;
            spaceStart = false;
            leadingSpace = false;
            fBuffer.append(attValue[i]);
            count++;
        }
    }

    // check if the last appended character is a space.
    if (count > 0 && fBuffer.charAt(count-1) == ' ') {
        fBuffer.setLength(count-1);
        /*** BUG #3512 ***
        int entityCount = attributes.getEntityCount(index);
        for (int j=0;  j < entityCount; j++) {
            int offset = attributes.getEntityOffset(index, j);
            int length = attributes.getEntityLength(index, j);
            if (offset < count-1) {
                if (offset+length == count) {
                    length--;
                }
            }
            else {
                offset--;
            }
            attributes.setEntityOffset(index, j, offset);
            attributes.setEntityLength(index, j, length);
        }
        /***/
    }
    String newValue = fBuffer.toString();
    attributes.setValue(index, newValue);
    return ! attrValue.equals(newValue);
}
 
Example 9
Source File: DTDGrammarUtil.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Normalize the attribute value of a non CDATA attributes collapsing
 * sequences of space characters (x20)
 *
 * @param attributes The list of attributes
 * @param index The index of the attribute to normalize
 */
private boolean normalizeAttrValue(XMLAttributes attributes, int index) {
    // vars
    boolean leadingSpace = true;
    boolean spaceStart = false;
    boolean readingNonSpace = false;
    int count = 0;
    int eaten = 0;
    String attrValue = attributes.getValue(index);
    char[] attValue = new char[attrValue.length()];

    fBuffer.setLength(0);
    attrValue.getChars(0, attrValue.length(), attValue, 0);
    for (int i = 0; i < attValue.length; i++) {

        if (attValue[i] == ' ') {

            // now the tricky part
            if (readingNonSpace) {
                spaceStart = true;
                readingNonSpace = false;
            }

            if (spaceStart && !leadingSpace) {
                spaceStart = false;
                fBuffer.append(attValue[i]);
                count++;
            } else {
                if (leadingSpace || !spaceStart) {
                    eaten++;
                }
            }

        } else {
            readingNonSpace = true;
            spaceStart = false;
            leadingSpace = false;
            fBuffer.append(attValue[i]);
            count++;
        }
    }

    // check if the last appended character is a space.
    if (count > 0 && fBuffer.charAt(count - 1) == ' ') {
        fBuffer.setLength(count - 1);

    }
    String newValue = fBuffer.toString();
    attributes.setValue(index, newValue);
    return !attrValue.equals(newValue);
}
 
Example 10
Source File: XMLDocumentFragmentScannerImpl.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Scans an attribute name value pair.
 * <p>
 * <pre>
 * [41] Attribute ::= Name Eq AttValue
 * </pre>
 * <p>
 * <strong>Note:</strong> This method assumes that the next
 * character on the stream is the first character of the attribute
 * name.
 * <p>
 * <strong>Note:</strong> This method uses the fAttributeQName and
 * fQName variables. The contents of these variables will be
 * destroyed.
 *
 * @param attributes The attributes list for the scanned attribute.
 */

protected void scanAttribute(XMLAttributes attributes)
throws IOException, XNIException {
    if (DEBUG_START_END_ELEMENT) System.out.println(this.getClass().toString() +">>> scanAttribute()");

    // name
    if (fNamespaces) {
        fEntityScanner.scanQName(fAttributeQName, NameType.ATTRIBUTENAME);
    } else {
        String name = fEntityScanner.scanName(NameType.ATTRIBUTENAME);
        fAttributeQName.setValues(null, name, name, null);
    }

    // equals
    fEntityScanner.skipSpaces();
    if (!fEntityScanner.skipChar('=', NameType.ATTRIBUTE)) {
        reportFatalError("EqRequiredInAttribute",
            new Object[] {fCurrentElement.rawname, fAttributeQName.rawname});
    }
    fEntityScanner.skipSpaces();

    int attIndex = 0 ;
    //REVISIT: one more case needs to be included: external PE and standalone is no
    boolean isVC =  fHasExternalDTD && !fStandalone;
    //fTempString would store attribute value
    ///fTempString2 would store attribute non-normalized value

    //this function doesn't use 'attIndex'. We are adding the attribute later
    //after we have figured out that current attribute is not namespace declaration
    //since scanAttributeValue doesn't use attIndex parameter therefore we
    //can safely add the attribute later..
    XMLString tmpStr = getString();

    scanAttributeValue(tmpStr, fTempString2, fAttributeQName.rawname, attributes,
            attIndex, isVC, fCurrentElement.rawname, false);

    // content
    int oldLen = attributes.getLength();
    //if the attribute name already exists.. new value is replaced with old value
    attIndex = attributes.addAttribute(fAttributeQName, XMLSymbols.fCDATASymbol, null);

    // WFC: Unique Att Spec
    //attributes count will be same if the current attribute  name already exists for this element name.
    //this means there are two duplicate attributes.
    if (oldLen == attributes.getLength()) {
        reportFatalError("AttributeNotUnique",
                new Object[]{fCurrentElement.rawname,
                        fAttributeQName.rawname});
    }

    //tmpString contains attribute value
    //we are passing null as the attribute value
    attributes.setValue(attIndex, null, tmpStr);

    ///xxx: nonNormalizedValue is not being set as it is not required by SAX & DOM
    //attributes.setNonNormalizedValue(oldLen, fTempString2.toString());
    attributes.setSpecified(attIndex, true);

    if (DEBUG_START_END_ELEMENT) System.out.println(this.getClass().toString() +"<<< scanAttribute()");

}
 
Example 11
Source File: XMLDTDValidator.java    From jdk1.8-source-analysis with Apache License 2.0 4 votes vote down vote up
/**
 * Normalize the attribute value of a non CDATA attributes collapsing
 * sequences of space characters (x20)
 *
 * @param attributes The list of attributes
 * @param index The index of the attribute to normalize
 */
private boolean normalizeAttrValue(XMLAttributes attributes, int index) {
    // vars
    boolean leadingSpace = true;
    boolean spaceStart = false;
    boolean readingNonSpace = false;
    int count = 0;
    int eaten = 0;
    String attrValue = attributes.getValue(index);
    char[] attValue = new char[attrValue.length()];

    fBuffer.setLength(0);
    attrValue.getChars(0, attrValue.length(), attValue, 0);
    for (int i = 0; i < attValue.length; i++) {

        if (attValue[i] == ' ') {

            // now the tricky part
            if (readingNonSpace) {
                spaceStart = true;
                readingNonSpace = false;
            }

            if (spaceStart && !leadingSpace) {
                spaceStart = false;
                fBuffer.append(attValue[i]);
                count++;
            }
            else {
                if (leadingSpace || !spaceStart) {
                    eaten ++;
                    /*** BUG #3512 ***
                    int entityCount = attributes.getEntityCount(index);
                    for (int j = 0;  j < entityCount; j++) {
                        int offset = attributes.getEntityOffset(index, j);
                        int length = attributes.getEntityLength(index, j);
                        if (offset <= i-eaten+1) {
                            if (offset+length >= i-eaten+1) {
                                if (length > 0)
                                    length--;
                            }
                        }
                        else {
                            if (offset > 0)
                                offset--;
                        }
                        attributes.setEntityOffset(index, j, offset);
                        attributes.setEntityLength(index, j, length);
                    }
                    /***/
                }
            }

        }
        else {
            readingNonSpace = true;
            spaceStart = false;
            leadingSpace = false;
            fBuffer.append(attValue[i]);
            count++;
        }
    }

    // check if the last appended character is a space.
    if (count > 0 && fBuffer.charAt(count-1) == ' ') {
        fBuffer.setLength(count-1);
        /*** BUG #3512 ***
        int entityCount = attributes.getEntityCount(index);
        for (int j=0;  j < entityCount; j++) {
            int offset = attributes.getEntityOffset(index, j);
            int length = attributes.getEntityLength(index, j);
            if (offset < count-1) {
                if (offset+length == count) {
                    length--;
                }
            }
            else {
                offset--;
            }
            attributes.setEntityOffset(index, j, offset);
            attributes.setEntityLength(index, j, length);
        }
        /***/
    }
    String newValue = fBuffer.toString();
    attributes.setValue(index, newValue);
    return ! attrValue.equals(newValue);
}
 
Example 12
Source File: XMLDocumentFragmentScannerImpl.java    From JDKSourceCode1.8 with MIT License 4 votes vote down vote up
/**
 * Scans an attribute name value pair.
 * <p>
 * <pre>
 * [41] Attribute ::= Name Eq AttValue
 * </pre>
 * <p>
 * <strong>Note:</strong> This method assumes that the next
 * character on the stream is the first character of the attribute
 * name.
 * <p>
 * <strong>Note:</strong> This method uses the fAttributeQName and
 * fQName variables. The contents of these variables will be
 * destroyed.
 *
 * @param attributes The attributes list for the scanned attribute.
 */

protected void scanAttribute(XMLAttributes attributes)
throws IOException, XNIException {
    if (DEBUG_START_END_ELEMENT) System.out.println(this.getClass().toString() +">>> scanAttribute()");

    // name
    if (fNamespaces) {
        fEntityScanner.scanQName(fAttributeQName, NameType.ATTRIBUTENAME);
    } else {
        String name = fEntityScanner.scanName(NameType.ATTRIBUTENAME);
        fAttributeQName.setValues(null, name, name, null);
    }

    // equals
    fEntityScanner.skipSpaces();
    if (!fEntityScanner.skipChar('=', NameType.ATTRIBUTE)) {
        reportFatalError("EqRequiredInAttribute",
            new Object[] {fCurrentElement.rawname, fAttributeQName.rawname});
    }
    fEntityScanner.skipSpaces();

    int attIndex = 0 ;
    //REVISIT: one more case needs to be included: external PE and standalone is no
    boolean isVC =  fHasExternalDTD && !fStandalone;
    //fTempString would store attribute value
    ///fTempString2 would store attribute non-normalized value

    //this function doesn't use 'attIndex'. We are adding the attribute later
    //after we have figured out that current attribute is not namespace declaration
    //since scanAttributeValue doesn't use attIndex parameter therefore we
    //can safely add the attribute later..
    XMLString tmpStr = getString();

    scanAttributeValue(tmpStr, fTempString2, fAttributeQName.rawname, attributes,
            attIndex, isVC, fCurrentElement.rawname, false);

    // content
    int oldLen = attributes.getLength();
    //if the attribute name already exists.. new value is replaced with old value
    attIndex = attributes.addAttribute(fAttributeQName, XMLSymbols.fCDATASymbol, null);

    // WFC: Unique Att Spec
    //attributes count will be same if the current attribute  name already exists for this element name.
    //this means there are two duplicate attributes.
    if (oldLen == attributes.getLength()) {
        reportFatalError("AttributeNotUnique",
                new Object[]{fCurrentElement.rawname,
                        fAttributeQName.rawname});
    }

    //tmpString contains attribute value
    //we are passing null as the attribute value
    attributes.setValue(attIndex, null, tmpStr);

    ///xxx: nonNormalizedValue is not being set as it is not required by SAX & DOM
    //attributes.setNonNormalizedValue(oldLen, fTempString2.toString());
    attributes.setSpecified(attIndex, true);

    if (DEBUG_START_END_ELEMENT) System.out.println(this.getClass().toString() +"<<< scanAttribute()");

}
 
Example 13
Source File: XMLDTDValidator.java    From JDKSourceCode1.8 with MIT License 4 votes vote down vote up
/**
 * Normalize the attribute value of a non CDATA attributes collapsing
 * sequences of space characters (x20)
 *
 * @param attributes The list of attributes
 * @param index The index of the attribute to normalize
 */
private boolean normalizeAttrValue(XMLAttributes attributes, int index) {
    // vars
    boolean leadingSpace = true;
    boolean spaceStart = false;
    boolean readingNonSpace = false;
    int count = 0;
    int eaten = 0;
    String attrValue = attributes.getValue(index);
    char[] attValue = new char[attrValue.length()];

    fBuffer.setLength(0);
    attrValue.getChars(0, attrValue.length(), attValue, 0);
    for (int i = 0; i < attValue.length; i++) {

        if (attValue[i] == ' ') {

            // now the tricky part
            if (readingNonSpace) {
                spaceStart = true;
                readingNonSpace = false;
            }

            if (spaceStart && !leadingSpace) {
                spaceStart = false;
                fBuffer.append(attValue[i]);
                count++;
            }
            else {
                if (leadingSpace || !spaceStart) {
                    eaten ++;
                    /*** BUG #3512 ***
                    int entityCount = attributes.getEntityCount(index);
                    for (int j = 0;  j < entityCount; j++) {
                        int offset = attributes.getEntityOffset(index, j);
                        int length = attributes.getEntityLength(index, j);
                        if (offset <= i-eaten+1) {
                            if (offset+length >= i-eaten+1) {
                                if (length > 0)
                                    length--;
                            }
                        }
                        else {
                            if (offset > 0)
                                offset--;
                        }
                        attributes.setEntityOffset(index, j, offset);
                        attributes.setEntityLength(index, j, length);
                    }
                    /***/
                }
            }

        }
        else {
            readingNonSpace = true;
            spaceStart = false;
            leadingSpace = false;
            fBuffer.append(attValue[i]);
            count++;
        }
    }

    // check if the last appended character is a space.
    if (count > 0 && fBuffer.charAt(count-1) == ' ') {
        fBuffer.setLength(count-1);
        /*** BUG #3512 ***
        int entityCount = attributes.getEntityCount(index);
        for (int j=0;  j < entityCount; j++) {
            int offset = attributes.getEntityOffset(index, j);
            int length = attributes.getEntityLength(index, j);
            if (offset < count-1) {
                if (offset+length == count) {
                    length--;
                }
            }
            else {
                offset--;
            }
            attributes.setEntityOffset(index, j, offset);
            attributes.setEntityLength(index, j, length);
        }
        /***/
    }
    String newValue = fBuffer.toString();
    attributes.setValue(index, newValue);
    return ! attrValue.equals(newValue);
}
 
Example 14
Source File: XMLDTDValidator.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Normalize the attribute value of a non CDATA attributes collapsing
 * sequences of space characters (x20)
 *
 * @param attributes The list of attributes
 * @param index The index of the attribute to normalize
 */
private boolean normalizeAttrValue(XMLAttributes attributes, int index) {
    // vars
    boolean leadingSpace = true;
    boolean spaceStart = false;
    boolean readingNonSpace = false;
    int count = 0;
    int eaten = 0;
    String attrValue = attributes.getValue(index);
    char[] attValue = new char[attrValue.length()];

    fBuffer.setLength(0);
    attrValue.getChars(0, attrValue.length(), attValue, 0);
    for (int i = 0; i < attValue.length; i++) {

        if (attValue[i] == ' ') {

            // now the tricky part
            if (readingNonSpace) {
                spaceStart = true;
                readingNonSpace = false;
            }

            if (spaceStart && !leadingSpace) {
                spaceStart = false;
                fBuffer.append(attValue[i]);
                count++;
            }
            else {
                if (leadingSpace || !spaceStart) {
                    eaten ++;
                    /*** BUG #3512 ***
                    int entityCount = attributes.getEntityCount(index);
                    for (int j = 0;  j < entityCount; j++) {
                        int offset = attributes.getEntityOffset(index, j);
                        int length = attributes.getEntityLength(index, j);
                        if (offset <= i-eaten+1) {
                            if (offset+length >= i-eaten+1) {
                                if (length > 0)
                                    length--;
                            }
                        }
                        else {
                            if (offset > 0)
                                offset--;
                        }
                        attributes.setEntityOffset(index, j, offset);
                        attributes.setEntityLength(index, j, length);
                    }
                    /***/
                }
            }

        }
        else {
            readingNonSpace = true;
            spaceStart = false;
            leadingSpace = false;
            fBuffer.append(attValue[i]);
            count++;
        }
    }

    // check if the last appended character is a space.
    if (count > 0 && fBuffer.charAt(count-1) == ' ') {
        fBuffer.setLength(count-1);
        /*** BUG #3512 ***
        int entityCount = attributes.getEntityCount(index);
        for (int j=0;  j < entityCount; j++) {
            int offset = attributes.getEntityOffset(index, j);
            int length = attributes.getEntityLength(index, j);
            if (offset < count-1) {
                if (offset+length == count) {
                    length--;
                }
            }
            else {
                offset--;
            }
            attributes.setEntityOffset(index, j, offset);
            attributes.setEntityLength(index, j, length);
        }
        /***/
    }
    String newValue = fBuffer.toString();
    attributes.setValue(index, newValue);
    return ! attrValue.equals(newValue);
}
 
Example 15
Source File: XMLDTDValidator.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Normalize the attribute value of a non CDATA attributes collapsing
 * sequences of space characters (x20)
 *
 * @param attributes The list of attributes
 * @param index The index of the attribute to normalize
 */
private boolean normalizeAttrValue(XMLAttributes attributes, int index) {
    // vars
    boolean leadingSpace = true;
    boolean spaceStart = false;
    boolean readingNonSpace = false;
    int count = 0;
    int eaten = 0;
    String attrValue = attributes.getValue(index);
    char[] attValue = new char[attrValue.length()];

    fBuffer.setLength(0);
    attrValue.getChars(0, attrValue.length(), attValue, 0);
    for (int i = 0; i < attValue.length; i++) {

        if (attValue[i] == ' ') {

            // now the tricky part
            if (readingNonSpace) {
                spaceStart = true;
                readingNonSpace = false;
            }

            if (spaceStart && !leadingSpace) {
                spaceStart = false;
                fBuffer.append(attValue[i]);
                count++;
            }
            else {
                if (leadingSpace || !spaceStart) {
                    eaten ++;
                    /*** BUG #3512 ***
                    int entityCount = attributes.getEntityCount(index);
                    for (int j = 0;  j < entityCount; j++) {
                        int offset = attributes.getEntityOffset(index, j);
                        int length = attributes.getEntityLength(index, j);
                        if (offset <= i-eaten+1) {
                            if (offset+length >= i-eaten+1) {
                                if (length > 0)
                                    length--;
                            }
                        }
                        else {
                            if (offset > 0)
                                offset--;
                        }
                        attributes.setEntityOffset(index, j, offset);
                        attributes.setEntityLength(index, j, length);
                    }
                    /***/
                }
            }

        }
        else {
            readingNonSpace = true;
            spaceStart = false;
            leadingSpace = false;
            fBuffer.append(attValue[i]);
            count++;
        }
    }

    // check if the last appended character is a space.
    if (count > 0 && fBuffer.charAt(count-1) == ' ') {
        fBuffer.setLength(count-1);
        /*** BUG #3512 ***
        int entityCount = attributes.getEntityCount(index);
        for (int j=0;  j < entityCount; j++) {
            int offset = attributes.getEntityOffset(index, j);
            int length = attributes.getEntityLength(index, j);
            if (offset < count-1) {
                if (offset+length == count) {
                    length--;
                }
            }
            else {
                offset--;
            }
            attributes.setEntityOffset(index, j, offset);
            attributes.setEntityLength(index, j, length);
        }
        /***/
    }
    String newValue = fBuffer.toString();
    attributes.setValue(index, newValue);
    return ! attrValue.equals(newValue);
}
 
Example 16
Source File: XMLDTDValidator.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Normalize the attribute value of a non CDATA attributes collapsing
 * sequences of space characters (x20)
 *
 * @param attributes The list of attributes
 * @param index The index of the attribute to normalize
 */
private boolean normalizeAttrValue(XMLAttributes attributes, int index) {
    // vars
    boolean leadingSpace = true;
    boolean spaceStart = false;
    boolean readingNonSpace = false;
    int count = 0;
    int eaten = 0;
    String attrValue = attributes.getValue(index);
    char[] attValue = new char[attrValue.length()];

    fBuffer.setLength(0);
    attrValue.getChars(0, attrValue.length(), attValue, 0);
    for (int i = 0; i < attValue.length; i++) {

        if (attValue[i] == ' ') {

            // now the tricky part
            if (readingNonSpace) {
                spaceStart = true;
                readingNonSpace = false;
            }

            if (spaceStart && !leadingSpace) {
                spaceStart = false;
                fBuffer.append(attValue[i]);
                count++;
            }
            else {
                if (leadingSpace || !spaceStart) {
                    eaten ++;
                    /*** BUG #3512 ***
                    int entityCount = attributes.getEntityCount(index);
                    for (int j = 0;  j < entityCount; j++) {
                        int offset = attributes.getEntityOffset(index, j);
                        int length = attributes.getEntityLength(index, j);
                        if (offset <= i-eaten+1) {
                            if (offset+length >= i-eaten+1) {
                                if (length > 0)
                                    length--;
                            }
                        }
                        else {
                            if (offset > 0)
                                offset--;
                        }
                        attributes.setEntityOffset(index, j, offset);
                        attributes.setEntityLength(index, j, length);
                    }
                    /***/
                }
            }

        }
        else {
            readingNonSpace = true;
            spaceStart = false;
            leadingSpace = false;
            fBuffer.append(attValue[i]);
            count++;
        }
    }

    // check if the last appended character is a space.
    if (count > 0 && fBuffer.charAt(count-1) == ' ') {
        fBuffer.setLength(count-1);
        /*** BUG #3512 ***
        int entityCount = attributes.getEntityCount(index);
        for (int j=0;  j < entityCount; j++) {
            int offset = attributes.getEntityOffset(index, j);
            int length = attributes.getEntityLength(index, j);
            if (offset < count-1) {
                if (offset+length == count) {
                    length--;
                }
            }
            else {
                offset--;
            }
            attributes.setEntityOffset(index, j, offset);
            attributes.setEntityLength(index, j, length);
        }
        /***/
    }
    String newValue = fBuffer.toString();
    attributes.setValue(index, newValue);
    return ! attrValue.equals(newValue);
}
 
Example 17
Source File: DTDGrammarUtil.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Normalize the attribute value of a non CDATA attributes collapsing
 * sequences of space characters (x20)
 *
 * @param attributes The list of attributes
 * @param index The index of the attribute to normalize
 */
private boolean normalizeAttrValue(XMLAttributes attributes, int index) {
    // vars
    boolean leadingSpace = true;
    boolean spaceStart = false;
    boolean readingNonSpace = false;
    int count = 0;
    int eaten = 0;
    String attrValue = attributes.getValue(index);
    char[] attValue = new char[attrValue.length()];

    fBuffer.setLength(0);
    attrValue.getChars(0, attrValue.length(), attValue, 0);
    for (int i = 0; i < attValue.length; i++) {

        if (attValue[i] == ' ') {

            // now the tricky part
            if (readingNonSpace) {
                spaceStart = true;
                readingNonSpace = false;
            }

            if (spaceStart && !leadingSpace) {
                spaceStart = false;
                fBuffer.append(attValue[i]);
                count++;
            } else {
                if (leadingSpace || !spaceStart) {
                    eaten++;
                }
            }

        } else {
            readingNonSpace = true;
            spaceStart = false;
            leadingSpace = false;
            fBuffer.append(attValue[i]);
            count++;
        }
    }

    // check if the last appended character is a space.
    if (count > 0 && fBuffer.charAt(count - 1) == ' ') {
        fBuffer.setLength(count - 1);

    }
    String newValue = fBuffer.toString();
    attributes.setValue(index, newValue);
    return !attrValue.equals(newValue);
}
 
Example 18
Source File: XMLDocumentFragmentScannerImpl.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Scans an attribute name value pair.
 * <p>
 * <pre>
 * [41] Attribute ::= Name Eq AttValue
 * </pre>
 * <p>
 * <strong>Note:</strong> This method assumes that the next
 * character on the stream is the first character of the attribute
 * name.
 * <p>
 * <strong>Note:</strong> This method uses the fAttributeQName and
 * fQName variables. The contents of these variables will be
 * destroyed.
 *
 * @param attributes The attributes list for the scanned attribute.
 */

protected void scanAttribute(XMLAttributes attributes)
throws IOException, XNIException {
    if (DEBUG_START_END_ELEMENT) System.out.println(this.getClass().toString() +">>> scanAttribute()");

    // name
    if (fNamespaces) {
        fEntityScanner.scanQName(fAttributeQName, NameType.ATTRIBUTENAME);
    } else {
        String name = fEntityScanner.scanName(NameType.ATTRIBUTENAME);
        fAttributeQName.setValues(null, name, name, null);
    }

    // equals
    fEntityScanner.skipSpaces();
    if (!fEntityScanner.skipChar('=', NameType.ATTRIBUTE)) {
        reportFatalError("EqRequiredInAttribute",
            new Object[] {fCurrentElement.rawname, fAttributeQName.rawname});
    }
    fEntityScanner.skipSpaces();

    int attIndex = 0 ;
    //REVISIT: one more case needs to be included: external PE and standalone is no
    boolean isVC =  fHasExternalDTD && !fStandalone;
    //fTempString would store attribute value
    ///fTempString2 would store attribute non-normalized value

    //this function doesn't use 'attIndex'. We are adding the attribute later
    //after we have figured out that current attribute is not namespace declaration
    //since scanAttributeValue doesn't use attIndex parameter therefore we
    //can safely add the attribute later..
    XMLString tmpStr = getString();

    scanAttributeValue(tmpStr, fTempString2, fAttributeQName.rawname, attributes,
            attIndex, isVC, fCurrentElement.rawname, false);

    // content
    int oldLen = attributes.getLength();
    //if the attribute name already exists.. new value is replaced with old value
    attIndex = attributes.addAttribute(fAttributeQName, XMLSymbols.fCDATASymbol, null);

    // WFC: Unique Att Spec
    //attributes count will be same if the current attribute  name already exists for this element name.
    //this means there are two duplicate attributes.
    if (oldLen == attributes.getLength()) {
        reportFatalError("AttributeNotUnique",
                new Object[]{fCurrentElement.rawname,
                        fAttributeQName.rawname});
    }

    //tmpString contains attribute value
    //we are passing null as the attribute value
    attributes.setValue(attIndex, null, tmpStr);

    ///xxx: nonNormalizedValue is not being set as it is not required by SAX & DOM
    //attributes.setNonNormalizedValue(oldLen, fTempString2.toString());
    attributes.setSpecified(attIndex, true);

    if (DEBUG_START_END_ELEMENT) System.out.println(this.getClass().toString() +"<<< scanAttribute()");

}
 
Example 19
Source File: XMLDTDValidator.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Normalize the attribute value of a non CDATA attributes collapsing
 * sequences of space characters (x20)
 *
 * @param attributes The list of attributes
 * @param index The index of the attribute to normalize
 */
private boolean normalizeAttrValue(XMLAttributes attributes, int index) {
    // vars
    boolean leadingSpace = true;
    boolean spaceStart = false;
    boolean readingNonSpace = false;
    int count = 0;
    int eaten = 0;
    String attrValue = attributes.getValue(index);
    char[] attValue = new char[attrValue.length()];

    fBuffer.setLength(0);
    attrValue.getChars(0, attrValue.length(), attValue, 0);
    for (int i = 0; i < attValue.length; i++) {

        if (attValue[i] == ' ') {

            // now the tricky part
            if (readingNonSpace) {
                spaceStart = true;
                readingNonSpace = false;
            }

            if (spaceStart && !leadingSpace) {
                spaceStart = false;
                fBuffer.append(attValue[i]);
                count++;
            }
            else {
                if (leadingSpace || !spaceStart) {
                    eaten ++;
                    /*** BUG #3512 ***
                    int entityCount = attributes.getEntityCount(index);
                    for (int j = 0;  j < entityCount; j++) {
                        int offset = attributes.getEntityOffset(index, j);
                        int length = attributes.getEntityLength(index, j);
                        if (offset <= i-eaten+1) {
                            if (offset+length >= i-eaten+1) {
                                if (length > 0)
                                    length--;
                            }
                        }
                        else {
                            if (offset > 0)
                                offset--;
                        }
                        attributes.setEntityOffset(index, j, offset);
                        attributes.setEntityLength(index, j, length);
                    }
                    /***/
                }
            }

        }
        else {
            readingNonSpace = true;
            spaceStart = false;
            leadingSpace = false;
            fBuffer.append(attValue[i]);
            count++;
        }
    }

    // check if the last appended character is a space.
    if (count > 0 && fBuffer.charAt(count-1) == ' ') {
        fBuffer.setLength(count-1);
        /*** BUG #3512 ***
        int entityCount = attributes.getEntityCount(index);
        for (int j=0;  j < entityCount; j++) {
            int offset = attributes.getEntityOffset(index, j);
            int length = attributes.getEntityLength(index, j);
            if (offset < count-1) {
                if (offset+length == count) {
                    length--;
                }
            }
            else {
                offset--;
            }
            attributes.setEntityOffset(index, j, offset);
            attributes.setEntityLength(index, j, length);
        }
        /***/
    }
    String newValue = fBuffer.toString();
    attributes.setValue(index, newValue);
    return ! attrValue.equals(newValue);
}
 
Example 20
Source File: XMLDocumentFragmentScannerImpl.java    From jdk1.8-source-analysis with Apache License 2.0 4 votes vote down vote up
/**
 * Scans an attribute name value pair.
 * <p>
 * <pre>
 * [41] Attribute ::= Name Eq AttValue
 * </pre>
 * <p>
 * <strong>Note:</strong> This method assumes that the next
 * character on the stream is the first character of the attribute
 * name.
 * <p>
 * <strong>Note:</strong> This method uses the fAttributeQName and
 * fQName variables. The contents of these variables will be
 * destroyed.
 *
 * @param attributes The attributes list for the scanned attribute.
 */

protected void scanAttribute(XMLAttributes attributes)
throws IOException, XNIException {
    if (DEBUG_START_END_ELEMENT) System.out.println(this.getClass().toString() +">>> scanAttribute()");

    // name
    if (fNamespaces) {
        fEntityScanner.scanQName(fAttributeQName, NameType.ATTRIBUTENAME);
    } else {
        String name = fEntityScanner.scanName(NameType.ATTRIBUTENAME);
        fAttributeQName.setValues(null, name, name, null);
    }

    // equals
    fEntityScanner.skipSpaces();
    if (!fEntityScanner.skipChar('=', NameType.ATTRIBUTE)) {
        reportFatalError("EqRequiredInAttribute",
            new Object[] {fCurrentElement.rawname, fAttributeQName.rawname});
    }
    fEntityScanner.skipSpaces();

    int attIndex = 0 ;
    //REVISIT: one more case needs to be included: external PE and standalone is no
    boolean isVC =  fHasExternalDTD && !fStandalone;
    //fTempString would store attribute value
    ///fTempString2 would store attribute non-normalized value

    //this function doesn't use 'attIndex'. We are adding the attribute later
    //after we have figured out that current attribute is not namespace declaration
    //since scanAttributeValue doesn't use attIndex parameter therefore we
    //can safely add the attribute later..
    XMLString tmpStr = getString();

    scanAttributeValue(tmpStr, fTempString2, fAttributeQName.rawname, attributes,
            attIndex, isVC, fCurrentElement.rawname, false);

    // content
    int oldLen = attributes.getLength();
    //if the attribute name already exists.. new value is replaced with old value
    attIndex = attributes.addAttribute(fAttributeQName, XMLSymbols.fCDATASymbol, null);

    // WFC: Unique Att Spec
    //attributes count will be same if the current attribute  name already exists for this element name.
    //this means there are two duplicate attributes.
    if (oldLen == attributes.getLength()) {
        reportFatalError("AttributeNotUnique",
                new Object[]{fCurrentElement.rawname,
                        fAttributeQName.rawname});
    }

    //tmpString contains attribute value
    //we are passing null as the attribute value
    attributes.setValue(attIndex, null, tmpStr);

    ///xxx: nonNormalizedValue is not being set as it is not required by SAX & DOM
    //attributes.setNonNormalizedValue(oldLen, fTempString2.toString());
    attributes.setSpecified(attIndex, true);

    if (DEBUG_START_END_ELEMENT) System.out.println(this.getClass().toString() +"<<< scanAttribute()");

}