Java Code Examples for com.sun.org.apache.xerces.internal.xni.XMLString

The following examples show how to use com.sun.org.apache.xerces.internal.xni.XMLString. These examples are extracted from open source projects. 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 Project: jdk8u60   Source File: XIncludeHandler.java    License: GNU General Public License v2.0 6 votes vote down vote up
@Override
public void processingInstruction(
    String target,
    XMLString data,
    Augmentations augs)
    throws XNIException {
    if (!fInDTD) {
        if (fDocumentHandler != null
            && getState() == STATE_NORMAL_PROCESSING) {
            // we need to change the depth like this so that modifyAugmentations() works
            fDepth++;
            augs = modifyAugmentations(augs);
            fDocumentHandler.processingInstruction(target, data, augs);
            fDepth--;
        }
    }
    else if (fDTDHandler != null) {
        fDTDHandler.processingInstruction(target, data, augs);
    }
}
 
Example 2
Source Project: JDKSourceCode1.8   Source File: ValidatorHandlerImpl.java    License: MIT License 6 votes vote down vote up
public void characters(XMLString text, Augmentations augs)
        throws XNIException {
    if (fContentHandler != null) {
        // if the type is union it is possible that we receive
        // a character call with empty data
        if (text.length == 0) {
            return;
        }
        try {
            fContentHandler.characters(text.ch, text.offset, text.length);
        }
        catch (SAXException e) {
            throw new XNIException(e);
        }
    }
}
 
Example 3
Source Project: JDKSourceCode1.8   Source File: DTDGrammar.java    License: MIT License 6 votes vote down vote up
/**
 * An internal entity declaration.
 *
 * @param name The name of the entity. Parameter entity names start with
 *             '%', whereas the name of a general entity is just the
 *             entity name.
 * @param text The value of the entity.
 * @param nonNormalizedText The non-normalized value of the entity. This
 *             value contains the same sequence of characters that was in
 *             the internal entity declaration, without any entity
 *             references expanded.
 * @param augs Additional information that may include infoset
 *                      augmentations.
 * @throws XNIException Thrown by handler to signal an error.
 */
public void internalEntityDecl(String name, XMLString text,
                               XMLString nonNormalizedText,
                               Augmentations augs) throws XNIException {

    int entityIndex = getEntityDeclIndex(name);
    if( entityIndex == -1){
        entityIndex = createEntityDecl();
        boolean isPE = name.startsWith("%");
        boolean inExternal = (fReadingExternalDTD || fPEDepth > 0);
        XMLEntityDecl  entityDecl = new XMLEntityDecl();
        entityDecl.setValues(name,null,null, null, null,
                             text.toString(), isPE, inExternal);

        setEntityDecl(entityIndex, entityDecl);
    }

}
 
Example 4
Source Project: openjdk-jdk8u   Source File: XMLScanner.java    License: GNU General Public License v2.0 6 votes vote down vote up
private void init() {
    // initialize scanner
    fEntityScanner = null;
    // initialize vars
    fEntityDepth = 0;
    fReportEntity = true;
    fResourceIdentifier.clear();

    if(!fAttributeCacheInitDone){
        for(int i = 0; i < initialCacheCount; i++){
            attributeValueCache.add(new XMLString());
            stringBufferCache.add(new XMLStringBuffer());
        }
        fAttributeCacheInitDone = true;
    }
    fStringBufferIndex = 0;
    fAttributeCacheUsedCount = 0;

}
 
Example 5
Source Project: openjdk-jdk9   Source File: XIncludeHandler.java    License: GNU General Public License v2.0 6 votes vote down vote up
@Override
public void comment(XMLString text, Augmentations augs)
    throws XNIException {
    if (!fInDTD) {
        if (fDocumentHandler != null
            && getState() == STATE_NORMAL_PROCESSING) {
            fDepth++;
            augs = modifyAugmentations(augs);
            fDocumentHandler.comment(text, augs);
            fDepth--;
        }
    }
    else if (fDTDHandler != null) {
        fDTDHandler.comment(text, augs);
    }
}
 
Example 6
Source Project: jdk1.8-source-analysis   Source File: XIncludeHandler.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void processingInstruction(
    String target,
    XMLString data,
    Augmentations augs)
    throws XNIException {
    if (!fInDTD) {
        if (fDocumentHandler != null
            && getState() == STATE_NORMAL_PROCESSING) {
            // we need to change the depth like this so that modifyAugmentations() works
            fDepth++;
            augs = modifyAugmentations(augs);
            fDocumentHandler.processingInstruction(target, data, augs);
            fDepth--;
        }
    }
    else if (fDTDHandler != null) {
        fDTDHandler.processingInstruction(target, data, augs);
    }
}
 
Example 7
public XMLString getCharacterData(){
    if(fUsebuffer){
        return fContentBuffer ;
    }else{
        return fTempString;
    }

}
 
Example 8
Source Project: Bytecoder   Source File: XML11DocumentScannerImpl.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Checks whether this string would be unchanged by normalization.
 *
 * @return -1 if the value would be unchanged by normalization,
 * otherwise the index of the first whitespace character which
 * would be transformed.
 */
protected int isUnchangedByNormalization(XMLString value) {
    int end = value.offset + value.length;
    for (int i = value.offset; i < end; ++i) {
        int c = value.ch[i];
        if (XMLChar.isSpace(c)) {
            return i - value.offset;
        }
    }
    return -1;
}
 
Example 9
public void internalEntityDecl(String name, XMLString text,
        XMLString nonNormalizedText, Augmentations augmentations)
        throws XNIException {
    if (fDTDHandler != null) {
        fDTDHandler.internalEntityDecl(name, text,
                nonNormalizedText, augmentations);
    }
}
 
Example 10
Source Project: JDKSourceCode1.8   Source File: XMLDocumentFragmentScannerImpl.java    License: MIT License 5 votes vote down vote up
/** this function gets an XMLString (which is used to store the attribute value) from the special pool
 *  maintained for attributes.
 *  fAttributeCacheUsedCount tracks the number of attributes that has been consumed from the pool.
 *  if all the attributes has been consumed, it adds a new XMLString inthe pool and returns the same
 *  XMLString.
 *
 * @return XMLString XMLString used to store an attribute value.
 */

protected XMLString getString(){
    if(fAttributeCacheUsedCount < initialCacheCount || fAttributeCacheUsedCount < attributeValueCache.size()){
        return attributeValueCache.get(fAttributeCacheUsedCount++);
    } else{
        XMLString str = new XMLString();
        fAttributeCacheUsedCount++;
        attributeValueCache.add(str);
        return str;
    }
}
 
Example 11
Source Project: Bytecoder   Source File: UnparsedEntityHandler.java    License: Apache License 2.0 5 votes vote down vote up
public void attributeDecl(String elementName, String attributeName,
        String type, String[] enumeration, String defaultType,
        XMLString defaultValue, XMLString nonNormalizedDefaultValue,
        Augmentations augmentations) throws XNIException {
    if (fDTDHandler != null) {
        fDTDHandler.attributeDecl(elementName, attributeName,
                type, enumeration, defaultType,
                defaultValue, nonNormalizedDefaultValue,
                augmentations);
    }
}
 
Example 12
Source Project: openjdk-jdk9   Source File: SchemaDOM.java    License: GNU General Public License v2.0 5 votes vote down vote up
void comment(XMLString text) {
    fAnnotationBuffer.append("<!--");
    if (text.length > 0) {
        fAnnotationBuffer.append(text.ch, text.offset, text.length);
    }
    fAnnotationBuffer.append("-->");
}
 
Example 13
Source Project: JDKSourceCode1.8   Source File: ValidatorHandlerImpl.java    License: MIT License 5 votes vote down vote up
public void processingInstruction(String target, XMLString data,
        Augmentations augs) throws XNIException {
    if (fContentHandler != null) {
        try {
            fContentHandler.processingInstruction(target, data.toString());
        }
        catch (SAXException e) {
            throw new XNIException(e);
        }
    }
}
 
Example 14
Source Project: openjdk-jdk9   Source File: DTDGrammarUtil.java    License: GNU General Public License v2.0 5 votes vote down vote up
public boolean isIgnorableWhiteSpace(XMLString text) {
    if (isInElementContent()) {
        for (int i = text.offset; i < text.offset + text.length; i++) {
            if (!XMLChar.isSpace(text.ch[i])) {
                return false;
            }
        }
        return true;
    }
    return false;
}
 
Example 15
Source Project: Bytecoder   Source File: XMLSchemaValidator.java    License: Apache License 2.0 5 votes vote down vote up
XMLString handleCharacters(XMLString text) {

        if (fSkipValidationDepth >= 0)
            return text;

        fSawText = fSawText || text.length > 0;

        // Note: data in EntityRef and CDATA is normalized as well
        // if whitespace == -1 skip normalization, because it is a complexType
        // or a union type.
        if (fNormalizeData && fWhiteSpace != -1 && fWhiteSpace != XSSimpleType.WS_PRESERVE) {
            // normalize data
            normalizeWhitespace(text, fWhiteSpace == XSSimpleType.WS_COLLAPSE);
            text = fNormalizedStr;
        }
        if (fAppendBuffer)
            fBuffer.append(text.ch, text.offset, text.length);

        // When it's a complex type with element-only content, we need to
        // find out whether the content contains any non-whitespace character.
        fSawOnlyWhitespaceInElementContent = false;
        if (fCurrentType != null
            && fCurrentType.getTypeCategory() == XSTypeDefinition.COMPLEX_TYPE) {
            XSComplexTypeDecl ctype = (XSComplexTypeDecl) fCurrentType;
            if (ctype.fContentType == XSComplexTypeDecl.CONTENTTYPE_ELEMENT) {
                // data outside of element content
                for (int i = text.offset; i < text.offset + text.length; i++) {
                    if (!XMLChar.isSpace(text.ch[i])) {
                        fSawCharacters = true;
                        break;
                    }
                    fSawOnlyWhitespaceInElementContent = !fSawCharacters;
                }
            }
        }

        return text;
    }
 
Example 16
Source Project: openjdk-jdk9   Source File: SAX2XNI.java    License: GNU General Public License v2.0 5 votes vote down vote up
public void characters( char[] buf, int offset, int len ) throws SAXException {
    try {
        fCore.characters(new XMLString(buf,offset,len),null);
    } catch( WrappedSAXException e ) {
        throw e.exception;
    }
}
 
Example 17
Source Project: jdk1.8-source-analysis   Source File: DOMResultAugmentor.java    License: Apache License 2.0 5 votes vote down vote up
public void characters(XMLString text, Augmentations augs)
        throws XNIException {
    if (!fIgnoreChars) {
        final Element currentElement = (Element) fDOMValidatorHelper.getCurrentElement();
        currentElement.appendChild(fDocument.createTextNode(text.toString()));
    }
}
 
Example 18
/** this function gets an XMLString (which is used to store the attribute value) from the special pool
 *  maintained for attributes.
 *  fAttributeCacheUsedCount tracks the number of attributes that has been consumed from the pool.
 *  if all the attributes has been consumed, it adds a new XMLString inthe pool and returns the same
 *  XMLString.
 *
 * @return XMLString XMLString used to store an attribute value.
 */

protected XMLString getString(){
    if(fAttributeCacheUsedCount < initialCacheCount || fAttributeCacheUsedCount < attributeValueCache.size()){
        return attributeValueCache.get(fAttributeCacheUsedCount++);
    } else{
        XMLString str = new XMLString();
        fAttributeCacheUsedCount++;
        attributeValueCache.add(str);
        return str;
    }
}
 
Example 19
/**
 * Normalize whitespace in an XMLString converting all whitespace
 * characters to space characters.
 */
protected void normalizeWhitespace(XMLString value) {
    int end = value.offset + value.length;
        for (int i = value.offset; i < end; ++i) {
       int c = value.ch[i];
       if (XMLChar.isSpace(c)) {
           value.ch[i] = ' ';
       }
   }
}
 
Example 20
Source Project: Bytecoder   Source File: XMLDocumentFragmentScannerImpl.java    License: Apache License 2.0 5 votes vote down vote up
/** this function gets an XMLString (which is used to store the attribute value) from the special pool
 *  maintained for attributes.
 *  fAttributeCacheUsedCount tracks the number of attributes that has been consumed from the pool.
 *  if all the attributes has been consumed, it adds a new XMLString inthe pool and returns the same
 *  XMLString.
 *
 * @return XMLString XMLString used to store an attribute value.
 */

protected XMLString getString(){
    if(fAttributeCacheUsedCount < initialCacheCount ||
            fAttributeCacheUsedCount < attributeValueCache.size()){
        return attributeValueCache.get(fAttributeCacheUsedCount++);
    } else{
        XMLString str = new XMLString();
        fAttributeCacheUsedCount++;
        attributeValueCache.add(str);
        return str;
    }
}
 
Example 21
Source Project: openjdk-8   Source File: XMLDTDProcessor.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * An internal entity declaration.
 *
 * @param name The name of the entity. Parameter entity names start with
 *             '%', whereas the name of a general entity is just the
 *             entity name.
 * @param text The value of the entity.
 * @param nonNormalizedText The non-normalized value of the entity. This
 *             value contains the same sequence of characters that was in
 *             the internal entity declaration, without any entity
 *             references expanded.
 * @param augs Additional information that may include infoset
 *                      augmentations.
 *
 * @throws XNIException Thrown by handler to signal an error.
 */
public void internalEntityDecl(String name, XMLString text,
                               XMLString nonNormalizedText,
                               Augmentations augs) throws XNIException {

    DTDGrammar grammar = (fDTDGrammar != null? fDTDGrammar: fGrammarBucket.getActiveGrammar());
    int index = grammar.getEntityDeclIndex(name) ;

    //If the same entity is declared more than once, the first declaration
    //encountered is binding, SAX requires only effective(first) declaration
    //to be reported to the application

    //REVISIT: Does it make sense to pass duplicate Entity information across
    //the pipeline -- nb?

    //its a new entity and hasn't been declared.
    if(index == -1){
        //store internal entity declaration in grammar
        if(fDTDGrammar != null)
            fDTDGrammar.internalEntityDecl(name, text, nonNormalizedText, augs);
        // call handlers
        if (fDTDHandler != null) {
            fDTDHandler.internalEntityDecl(name, text, nonNormalizedText, augs);
        }
    }

}
 
Example 22
/**
 * An internal entity declaration.
 *
 * @param name The name of the entity. Parameter entity names start with
 *             '%', whereas the name of a general entity is just the
 *             entity name.
 * @param text The value of the entity.
 * @param nonNormalizedText The non-normalized value of the entity. This
 *             value contains the same sequence of characters that was in
 *             the internal entity declaration, without any entity
 *             references expanded.
 * @param augs Additional information that may include infoset
 *                      augmentations.
 *
 * @throws XNIException Thrown by handler to signal an error.
 */
public void internalEntityDecl(String name, XMLString text,
                               XMLString nonNormalizedText,
                               Augmentations augs) throws XNIException {

    DTDGrammar grammar = (fDTDGrammar != null? fDTDGrammar: fGrammarBucket.getActiveGrammar());
    int index = grammar.getEntityDeclIndex(name) ;

    //If the same entity is declared more than once, the first declaration
    //encountered is binding, SAX requires only effective(first) declaration
    //to be reported to the application

    //REVISIT: Does it make sense to pass duplicate Entity information across
    //the pipeline -- nb?

    //its a new entity and hasn't been declared.
    if(index == -1){
        //store internal entity declaration in grammar
        if(fDTDGrammar != null)
            fDTDGrammar.internalEntityDecl(name, text, nonNormalizedText, augs);
        // call handlers
        if (fDTDHandler != null) {
            fDTDHandler.internalEntityDecl(name, text, nonNormalizedText, augs);
        }
    }

}
 
Example 23
public XMLString getCharacterData(){
    if(fUsebuffer){
        return fContentBuffer ;
    }else{
        return fTempString;
    }

}
 
Example 24
public void internalEntityDecl(String name, XMLString text,
        XMLString nonNormalizedText, Augmentations augmentations)
        throws XNIException {
    if (fDTDHandler != null) {
        fDTDHandler.internalEntityDecl(name, text,
                nonNormalizedText, augmentations);
    }
}
 
Example 25
Source Project: openjdk-jdk8u   Source File: SchemaDOM.java    License: GNU General Public License v2.0 5 votes vote down vote up
void characters(XMLString text) {

        // escape characters if necessary
        if (!inCDATA) {
            final StringBuffer annotationBuffer = fAnnotationBuffer;
            for (int i = text.offset; i < text.offset+text.length; ++i) {
                char ch = text.ch[i];
                if (ch == '&') {
                    annotationBuffer.append("&amp;");
                }
                else if (ch == '<') {
                    annotationBuffer.append("&lt;");
                }
                // character sequence "]]>" cannot appear in content,
                // therefore we should escape '>'.
                else if (ch == '>') {
                    annotationBuffer.append("&gt;");
                }
                // If CR is part of the document's content, it
                // must not be printed as a literal otherwise
                // it would be normalized to LF when the document
                // is reparsed.
                else if (ch == '\r') {
                    annotationBuffer.append("&#xD;");
                }
                else {
                    annotationBuffer.append(ch);
                }
            }
        }
        else {
            fAnnotationBuffer.append(text.ch, text.offset, text.length);
        }
    }
 
Example 26
Source Project: Bytecoder   Source File: SAX2XNI.java    License: Apache License 2.0 5 votes vote down vote up
public void ignorableWhitespace( char[] buf, int offset, int len ) throws SAXException {
    try {
        fCore.ignorableWhitespace(new XMLString(buf,offset,len),null);
    } catch( WrappedSAXException e ) {
        throw e.exception;
    }
}
 
Example 27
Source Project: jdk1.8-source-analysis   Source File: SAX2XNI.java    License: Apache License 2.0 5 votes vote down vote up
private XMLString createXMLString(String str) {
    // with my patch
    // return new XMLString(str);

    // for now
    return new XMLString(str.toCharArray(), 0, str.length());
}
 
Example 28
public void ignorableWhitespace(char[] ch, int start, int len) throws SAXException {
    try {
        handler().ignorableWhitespace(new XMLString(ch,start,len),aug());
    } catch( XNIException e ) {
        throw toSAXException(e);
    }
}
 
Example 29
Source Project: Bytecoder   Source File: SAX2XNI.java    License: Apache License 2.0 5 votes vote down vote up
private XMLString createXMLString(String str) {
    // with my patch
    // return new XMLString(str);

    // for now
    return new XMLString(str.toCharArray(), 0, str.length());
}
 
Example 30
Source Project: jdk1.8-source-analysis   Source File: XMLDTDScannerImpl.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Scans a processing data. This is needed to handle the situation
 * where a document starts with a processing instruction whose
 * target name <em>starts with</em> "xml". (e.g. xmlfoo)
 *
 * @param target The PI target
 * @param data The string to fill in with the data
 */
protected final void scanPIData(String target, XMLString data)
throws IOException, XNIException {
    //Venu REVISIT
    //      super.scanPIData(target, data);
    fMarkUpDepth--;

    // call handler
    if (fDTDHandler != null) {
        fDTDHandler.processingInstruction(target, data, null);
    }

}