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

The following examples show how to use com.sun.org.apache.xerces.internal.xni.XMLAttributes#getValue() . 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: XIncludeHandler.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Search for a xml:base attribute, and if one is found, put the new base URI into
 * effect.
 */
protected void processXMLBaseAttributes(XMLAttributes attributes) {
    String baseURIValue =
        attributes.getValue(NamespaceContext.XML_URI, "base");
    if (baseURIValue != null) {
        try {
            String expandedValue =
                XMLEntityManager.expandSystemId(
                    baseURIValue,
                    fCurrentBaseURI.getExpandedSystemId(),
                    false);
            fCurrentBaseURI.setLiteralSystemId(baseURIValue);
            fCurrentBaseURI.setBaseSystemId(
                fCurrentBaseURI.getExpandedSystemId());
            fCurrentBaseURI.setExpandedSystemId(expandedValue);

            // push the new values on the stack
            saveBaseURI();
        }
        catch (MalformedURIException e) {
            // REVISIT: throw error here
        }
    }
}
 
Example 2
Source File: XIncludeHandler.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
/**
 * Search for a xml:base attribute, and if one is found, put the new base URI into
 * effect.
 */
protected void processXMLBaseAttributes(XMLAttributes attributes) {
    String baseURIValue =
        attributes.getValue(NamespaceContext.XML_URI, "base");
    if (baseURIValue != null) {
        try {
            String expandedValue =
                XMLEntityManager.expandSystemId(
                    baseURIValue,
                    fCurrentBaseURI.getExpandedSystemId(),
                    false);
            fCurrentBaseURI.setLiteralSystemId(baseURIValue);
            fCurrentBaseURI.setBaseSystemId(
                fCurrentBaseURI.getExpandedSystemId());
            fCurrentBaseURI.setExpandedSystemId(expandedValue);

            // push the new values on the stack
            saveBaseURI();
        }
        catch (MalformedURIException e) {
            // REVISIT: throw error here
        }
    }
}
 
Example 3
Source File: SchemaDOM.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
void startAnnotationElement(String elemRawName, XMLAttributes attributes) {
    fAnnotationBuffer.append("<").append(elemRawName);
    for(int i=0; i<attributes.getLength(); i++) {
        String aValue = attributes.getValue(i);
        fAnnotationBuffer.append(" ").append(attributes.getQName(i)).append("=\"").append(processAttValue(aValue)).append("\"");
    }
    fAnnotationBuffer.append(">");
}
 
Example 4
Source File: ShortHandPointer.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Rerturns the DTD determine-ID
 *
 * @param attributes
 * @param index
 * @return String
 * @throws XNIException
 */
public String getDTDDeterminedID(XMLAttributes attributes, int index)
throws XNIException {

    if (attributes.getType(index).equals("ID")) {
        return attributes.getValue(index);
    }
    return null;
}
 
Example 5
Source File: XIncludeHandler.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
/**
 * Search for a xml:lang attribute, and if one is found, put the new
 * [language] into effect.
 */
protected void processXMLLangAttributes(XMLAttributes attributes) {
    String language = attributes.getValue(NamespaceContext.XML_URI, "lang");
    if (language != null) {
        fCurrentLanguage = language;
        saveLanguage(fCurrentLanguage);
    }
}
 
Example 6
Source File: XPointerElementHandler.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public boolean checkStringToken(QName element, XMLAttributes attributes){
    QName cacheQName = null;
    String id =null;
    String rawname =null;
    QName attrName = new QName();
    String attrType = null;
    String attrValue = null;
    int attrCount = attributes.getLength();
    for (int i = 0; i < attrCount; i++) {
        Augmentations aaugs = attributes.getAugmentations(i);
        attributes.getName(i,attrName);
        attrType = attributes.getType(i);
        attrValue = attributes.getValue(i);
        if(attrType != null && attrValue!= null && isIdAttribute(attributes,aaugs,i) && attrValue.equals(fCurrentTokenString)){
            if(hasMoreToken()){
                fCurrentTokenType = 0;
                fCurrentTokenString = null;
                return true;
            }
            else{
                foundElement = element;
                includeElement = true;
                fCurrentTokenType = 0;
                fCurrentTokenString = null;
                fSubResourceIdentified = true;
                return true;
            }
        }
    }
    return false;
}
 
Example 7
Source File: ShortHandPointer.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Rerturns the DTD determine-ID
 *
 * @param attributes
 * @param index
 * @return String
 * @throws XNIException
 */
public String getDTDDeterminedID(XMLAttributes attributes, int index)
throws XNIException {

    if (attributes.getType(index).equals("ID")) {
        return attributes.getValue(index);
    }
    return null;
}
 
Example 8
Source File: ShortHandPointer.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Rerturns the DTD determine-ID
 *
 * @param attributes
 * @param index
 * @return String
 * @throws XNIException
 */
public String getDTDDeterminedID(XMLAttributes attributes, int index)
throws XNIException {

    if (attributes.getType(index).equals("ID")) {
        return attributes.getValue(index);
    }
    return null;
}
 
Example 9
Source File: XIncludeHandler.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Search for a xml:lang attribute, and if one is found, put the new
 * [language] into effect.
 */
protected void processXMLLangAttributes(XMLAttributes attributes) {
    String language = attributes.getValue(NamespaceContext.XML_URI, "lang");
    if (language != null) {
        fCurrentLanguage = language;
        saveLanguage(fCurrentLanguage);
    }
}
 
Example 10
Source File: SchemaDOM.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
void startAnnotationElement(String elemRawName, XMLAttributes attributes) {
    fAnnotationBuffer.append("<").append(elemRawName);
    for(int i=0; i<attributes.getLength(); i++) {
        String aValue = attributes.getValue(i);
        fAnnotationBuffer.append(" ").append(attributes.getQName(i)).append("=\"").append(processAttValue(aValue)).append("\"");
    }
    fAnnotationBuffer.append(">");
}
 
Example 11
Source File: XIncludeHandler.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Search for a xml:lang attribute, and if one is found, put the new
 * [language] into effect.
 */
protected void processXMLLangAttributes(XMLAttributes attributes) {
    String language = attributes.getValue(NamespaceContext.XML_URI, "lang");
    if (language != null) {
        fCurrentLanguage = language;
        saveLanguage(fCurrentLanguage);
    }
}
 
Example 12
Source File: ShortHandPointer.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
/**
 * Rerturns the DTD determine-ID
 *
 * @param attributes
 * @param index
 * @return String
 * @throws XNIException
 */
public String getDTDDeterminedID(XMLAttributes attributes, int index)
throws XNIException {

    if (attributes.getType(index).equals("ID")) {
        return attributes.getValue(index);
    }
    return null;
}
 
Example 13
Source File: SchemaDOM.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
void startAnnotationElement(String elemRawName, XMLAttributes attributes) {
    fAnnotationBuffer.append("<").append(elemRawName);
    for(int i=0; i<attributes.getLength(); i++) {
        String aValue = attributes.getValue(i);
        fAnnotationBuffer.append(" ").append(attributes.getQName(i)).append("=\"").append(processAttValue(aValue)).append("\"");
    }
    fAnnotationBuffer.append(">");
}
 
Example 14
Source File: SchemaDOM.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
void startAnnotationElement(String elemRawName, XMLAttributes attributes) {
    fAnnotationBuffer.append("<").append(elemRawName);
    for(int i=0; i<attributes.getLength(); i++) {
        String aValue = attributes.getValue(i);
        fAnnotationBuffer.append(" ").append(attributes.getQName(i)).append("=\"").append(processAttValue(aValue)).append("\"");
    }
    fAnnotationBuffer.append(">");
}
 
Example 15
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 16
Source File: SchemaDOM.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
void startAnnotation(String elemRawName, XMLAttributes attributes,
        NamespaceContext namespaceContext) {
    if(fAnnotationBuffer == null) fAnnotationBuffer = new StringBuffer(256);
    fAnnotationBuffer.append("<").append(elemRawName).append(" ");

    // attributes are a bit of a pain.  To get this right, we have to keep track
    // of the namespaces we've seen declared, then examine the namespace context
    // for other namespaces so that we can also include them.
    // optimized for simplicity and the case that not many
    // namespaces are declared on this annotation...
    ArrayList namespaces = new ArrayList();
    for (int i = 0; i < attributes.getLength(); ++i) {
        String aValue = attributes.getValue(i);
        String aPrefix = attributes.getPrefix(i);
        String aQName = attributes.getQName(i);
        // if it's xmlns:* or xmlns, must be a namespace decl
        if (aPrefix == XMLSymbols.PREFIX_XMLNS || aQName == XMLSymbols.PREFIX_XMLNS) {
            namespaces.add(aPrefix == XMLSymbols.PREFIX_XMLNS ?
                    attributes.getLocalName(i) : XMLSymbols.EMPTY_STRING);
        }
        fAnnotationBuffer.append(aQName).append("=\"").append(processAttValue(aValue)).append("\" ");
    }
    // now we have to look through currently in-scope namespaces to see what
    // wasn't declared here
    Enumeration currPrefixes = namespaceContext.getAllPrefixes();
    while(currPrefixes.hasMoreElements()) {
        String prefix = (String)currPrefixes.nextElement();
        String uri = namespaceContext.getURI(prefix);
        if (uri == null) {
            uri = XMLSymbols.EMPTY_STRING;
        }
        if (!namespaces.contains(prefix)) {
            // have to declare this one
            if(prefix == XMLSymbols.EMPTY_STRING) {
                fAnnotationBuffer.append("xmlns").append("=\"").append(processAttValue(uri)).append("\" ");
            }
            else {
                fAnnotationBuffer.append("xmlns:").append(prefix).append("=\"").append(processAttValue(uri)).append("\" ");
            }
        }
    }
    fAnnotationBuffer.append(">\n");
}
 
Example 17
Source File: SchemaDOM.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
void startAnnotation(String elemRawName, XMLAttributes attributes,
        NamespaceContext namespaceContext) {
    if(fAnnotationBuffer == null) fAnnotationBuffer = new StringBuffer(256);
    fAnnotationBuffer.append("<").append(elemRawName).append(" ");

    // attributes are a bit of a pain.  To get this right, we have to keep track
    // of the namespaces we've seen declared, then examine the namespace context
    // for other namespaces so that we can also include them.
    // optimized for simplicity and the case that not many
    // namespaces are declared on this annotation...
    ArrayList namespaces = new ArrayList();
    for (int i = 0; i < attributes.getLength(); ++i) {
        String aValue = attributes.getValue(i);
        String aPrefix = attributes.getPrefix(i);
        String aQName = attributes.getQName(i);
        // if it's xmlns:* or xmlns, must be a namespace decl
        if (aPrefix == XMLSymbols.PREFIX_XMLNS || aQName == XMLSymbols.PREFIX_XMLNS) {
            namespaces.add(aPrefix == XMLSymbols.PREFIX_XMLNS ?
                    attributes.getLocalName(i) : XMLSymbols.EMPTY_STRING);
        }
        fAnnotationBuffer.append(aQName).append("=\"").append(processAttValue(aValue)).append("\" ");
    }
    // now we have to look through currently in-scope namespaces to see what
    // wasn't declared here
    Enumeration currPrefixes = namespaceContext.getAllPrefixes();
    while(currPrefixes.hasMoreElements()) {
        String prefix = (String)currPrefixes.nextElement();
        String uri = namespaceContext.getURI(prefix);
        if (uri == null) {
            uri = XMLSymbols.EMPTY_STRING;
        }
        if (!namespaces.contains(prefix)) {
            // have to declare this one
            if(prefix == XMLSymbols.EMPTY_STRING) {
                fAnnotationBuffer.append("xmlns").append("=\"").append(processAttValue(uri)).append("\" ");
            }
            else {
                fAnnotationBuffer.append("xmlns:").append(prefix).append("=\"").append(processAttValue(uri)).append("\" ");
            }
        }
    }
    fAnnotationBuffer.append(">\n");
}
 
Example 18
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 19
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 20
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);
}