com.sun.org.apache.xerces.internal.xni.QName Java Examples

The following examples show how to use com.sun.org.apache.xerces.internal.xni.QName. 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: XMLNSDTDValidator.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
/** Handles end element. */
protected void endNamespaceScope(QName element, Augmentations augs, boolean isEmpty)
    throws XNIException {

    // bind element
    String eprefix = element.prefix != null ? element.prefix : XMLSymbols.EMPTY_STRING;
    element.uri = fNamespaceContext.getURI(eprefix);
    if (element.uri != null) {
        element.prefix = eprefix;
    }

    // call handlers
    if (fDocumentHandler != null) {
        if (!isEmpty) {
            fDocumentHandler.endElement(element, augs);
        }
    }

    // pop context
    fNamespaceContext.popContext();

}
 
Example #2
Source File: DOMResultAugmentor.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
public void endElement(QName element, Augmentations augs)
        throws XNIException {
    final Node currentElement = fDOMValidatorHelper.getCurrentElement();
    // Write type information to this element
    if (augs != null && fDocumentImpl != null) {
        ElementPSVI elementPSVI = (ElementPSVI)augs.getItem(Constants.ELEMENT_PSVI);
        if (elementPSVI != null) {
            if (fStorePSVI) {
                ((PSVIElementNSImpl) currentElement).setPSVI(elementPSVI);
            }
            XSTypeDefinition type = elementPSVI.getMemberTypeDefinition();
            if (type == null) {
                type = elementPSVI.getTypeDefinition();
            }
            ((ElementNSImpl) currentElement).setType(type);
        }
    }
}
 
Example #3
Source File: DTDGrammar.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
private void ensureElementDeclCapacity(int chunk) {
    if (chunk >= fElementDeclName.length) {
        fElementDeclIsExternal = resize(fElementDeclIsExternal,
                                 fElementDeclIsExternal.length * 2);

        fElementDeclName = resize(fElementDeclName, fElementDeclName.length * 2);
        fElementDeclType = resize(fElementDeclType, fElementDeclType.length * 2);
        fElementDeclContentModelValidator = resize(fElementDeclContentModelValidator, fElementDeclContentModelValidator.length * 2);
        fElementDeclContentSpecIndex = resize(fElementDeclContentSpecIndex,fElementDeclContentSpecIndex.length * 2);
        fElementDeclFirstAttributeDeclIndex = resize(fElementDeclFirstAttributeDeclIndex, fElementDeclFirstAttributeDeclIndex.length * 2);
        fElementDeclLastAttributeDeclIndex = resize(fElementDeclLastAttributeDeclIndex, fElementDeclLastAttributeDeclIndex.length * 2);
    }
    else if (fElementDeclName[chunk] != null) {
        return;
    }

    fElementDeclIsExternal[chunk] = new int[CHUNK_SIZE];
    fElementDeclName[chunk] = new QName[CHUNK_SIZE];
    fElementDeclType[chunk] = new short[CHUNK_SIZE];
    fElementDeclContentModelValidator[chunk] = new ContentModelValidator[CHUNK_SIZE];
    fElementDeclContentSpecIndex[chunk] = new int[CHUNK_SIZE];
    fElementDeclFirstAttributeDeclIndex[chunk] = new int[CHUNK_SIZE];
    fElementDeclLastAttributeDeclIndex[chunk] = new int[CHUNK_SIZE];
    return;
}
 
Example #4
Source File: XMLStreamWriterImpl.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
boolean isDeclared(QName attr) {
    QName decl;

    for (int n = 0; n < fNamespaceDecls.size(); n++) {
        decl = fNamespaceDecls.get(n);

        if ((attr.prefix != null) &&
                ((attr.prefix.equals(decl.prefix)) && (decl.uri.equals(attr.uri)))) {
            return true;
        }
    }

    if (attr.uri != null) {
        if (fNamespaceContext.getPrefix(attr.uri) != null) {
            return true;
        }
    }

    return false;
}
 
Example #5
Source File: XMLDTDValidator.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/** ensure element stack capacity */
private void ensureStackCapacity (int newElementDepth) {
    if (newElementDepth == fElementQNamePartsStack.length) {

        QName[] newStackOfQueue = new QName[newElementDepth * 2];
        System.arraycopy(this.fElementQNamePartsStack, 0, newStackOfQueue, 0, newElementDepth );
        fElementQNamePartsStack = newStackOfQueue;

        QName qname = fElementQNamePartsStack[newElementDepth];
        if (qname == null) {
            for (int i = newElementDepth; i < fElementQNamePartsStack.length; i++) {
                fElementQNamePartsStack[i] = new QName();
            }
        }

        int[] newStack = new int[newElementDepth * 2];
        System.arraycopy(fElementIndexStack, 0, newStack, 0, newElementDepth);
        fElementIndexStack = newStack;

        newStack = new int[newElementDepth * 2];
        System.arraycopy(fContentSpecTypeStack, 0, newStack, 0, newElementDepth);
        fContentSpecTypeStack = newStack;

    }
}
 
Example #6
Source File: XSDFACM.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
Object findMatchingDecl(QName curElem, SubstitutionGroupHandler subGroupHandler) {
    Object matchingDecl = null;

    for (int elemIndex = 0; elemIndex < fElemMapSize; elemIndex++) {
        int type = fElemMapType[elemIndex] ;
        if (type == XSParticleDecl.PARTICLE_ELEMENT) {
            matchingDecl = subGroupHandler.getMatchingElemDecl(curElem, (XSElementDecl)fElemMap[elemIndex]);
            if (matchingDecl != null) {
                return matchingDecl;
            }
        }
        else if (type == XSParticleDecl.PARTICLE_WILDCARD) {
            if(((XSWildcardDecl)fElemMap[elemIndex]).allowNamespace(curElem.uri))
                return fElemMap[elemIndex];
        }
    }

    return null;
}
 
Example #7
Source File: XMLDocumentFragmentScannerImpl.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * This function doesn't increase depth. The function in this function is
 *broken down into two functions for efficiency. <@see>matchElement</see>.
 * This function just returns the pointer to the object and its values are set.
 *
 *@return QName reference to the next element in the list
 */
public QName nextElement() {

    //if number of elements becomes equal to the length of array -- stop the skipping
    if (fCount == fQName.length) {
        fShouldSkip = false;
        fAdd = false;
        if(DEBUG_SKIP_ALGORITHM)System.out.println("SKIPPING STOPPED, fShouldSkip = " + fShouldSkip);
        //xxx: this is not correct, we are returning the last element
        //this wont make any difference since flag has been set to 'false'
        return fQName[--fCount];
    }
    if(DEBUG_SKIP_ALGORITHM){
        System.out.println("fCount = " + fCount);
    }
    return fQName[fCount++];

}
 
Example #8
Source File: XMLDocumentFragmentScannerImpl.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Returns the next element on the stack.
 *
 * @return Returns the actual QName object. Callee should
 * use this object to store the details of next element encountered.
 */
public QName nextElement() {
    if(fSkip){
        fDepth++;
        //boundary checks are done in matchElement()
        return fElements[fCount++];
    } else if (fDepth == fElements.length) {
        QName[] array = new QName[fElements.length * 2];
        System.arraycopy(fElements, 0, array, 0, fDepth);
        fElements = array;
        for (int i = fDepth; i < fElements.length; i++) {
            fElements[i] = new QName();
        }
    }

    return fElements[fDepth++];

}
 
Example #9
Source File: XSDFACM.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
Object findMatchingDecl(QName curElem, SubstitutionGroupHandler subGroupHandler) {
    Object matchingDecl = null;

    for (int elemIndex = 0; elemIndex < fElemMapSize; elemIndex++) {
        int type = fElemMapType[elemIndex] ;
        if (type == XSParticleDecl.PARTICLE_ELEMENT) {
            matchingDecl = subGroupHandler.getMatchingElemDecl(curElem, (XSElementDecl)fElemMap[elemIndex]);
            if (matchingDecl != null) {
                return matchingDecl;
            }
        }
        else if (type == XSParticleDecl.PARTICLE_WILDCARD) {
            if(((XSWildcardDecl)fElemMap[elemIndex]).allowNamespace(curElem.uri))
                return fElemMap[elemIndex];
        }
    }

    return null;
}
 
Example #10
Source File: XMLSchemaValidator.java    From Bytecoder with Apache License 2.0 6 votes vote down vote up
/**
 * An empty element.
 *
 * @param element    The name of the element.
 * @param attributes The element attributes.
 * @param augs     Additional information that may include infoset augmentations
 *
 * @throws XNIException Thrown by handler to signal an error.
 */
public void emptyElement(QName element, XMLAttributes attributes, Augmentations augs)
    throws XNIException {

    Augmentations modifiedAugs = handleStartElement(element, attributes, augs);

    // in the case where there is a {value constraint}, and the element
    // doesn't have any text content, change emptyElement call to
    // start + characters + end
    fDefaultValue = null;
    // fElementDepth == -2 indicates that the schema validator was removed
    // from the pipeline. then we don't need to call handleEndElement.
    if (fElementDepth != -2)
        modifiedAugs = handleEndElement(element, modifiedAugs);

    // call handlers
    if (fDocumentHandler != null) {
        if (!fSchemaElementDefault || fDefaultValue == null) {
            fDocumentHandler.emptyElement(element, attributes, modifiedAugs);
        } else {
            fDocumentHandler.startElement(element, attributes, modifiedAugs);
            fDocumentHandler.characters(fDefaultValue, null);
            fDocumentHandler.endElement(element, modifiedAugs);
        }
    }
}
 
Example #11
Source File: ValidatorHandlerImpl.java    From Bytecoder with Apache License 2.0 6 votes vote down vote up
public void endElement(QName element, Augmentations augs)
        throws XNIException {
    if (fContentHandler != null) {
        try {
            fTypeInfoProvider.beginEndElement(augs);
            fContentHandler.endElement((element.uri != null) ? element.uri : XMLSymbols.EMPTY_STRING,
                    element.localpart, element.rawname);
        }
        catch (SAXException e) {
            throw new XNIException(e);
        }
        finally {
            fTypeInfoProvider.finishEndElement();
        }
    }
}
 
Example #12
Source File: XMLStreamWriterImpl.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Set the specified URI as default namespace in the current namespace context.
 *
 * @param uri Namespace URI
 */
public void setDefaultNamespace(String uri) throws XMLStreamException {
    if (uri != null) {
        uri = fSymbolTable.addSymbol(uri);
    }

    if (fIsRepairingNamespace) {
        if (isDefaultNamespace(uri)) {
            return;
        }

        QName qname = new QName();
        qname.setValues(DEFAULT_PREFIX, "xmlns", null, uri);
        fNamespaceDecls.add(qname);
    } else {
        fInternalNamespaceContext.declarePrefix(DEFAULT_PREFIX, uri);
    }
}
 
Example #13
Source File: ValidatorHandlerImpl.java    From Bytecoder with Apache License 2.0 6 votes vote down vote up
public void startElement(QName element, XMLAttributes attributes,
        Augmentations augs) throws XNIException {
    if (fContentHandler != null) {
        try {
            fTypeInfoProvider.beginStartElement(augs, attributes);
            fContentHandler.startElement((element.uri != null) ? element.uri : XMLSymbols.EMPTY_STRING,
                    element.localpart, element.rawname, fAttrAdapter);
        }
        catch (SAXException e) {
            throw new XNIException(e);
        }
        finally {
            fTypeInfoProvider.finishStartElement();
        }
    }
}
 
Example #14
Source File: XMLDTDValidator.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
/** Character data in content. */
private void charDataInContent() {

    if (DEBUG_ELEMENT_CHILDREN) {
        System.out.println("charDataInContent()");
    }
    if (fElementChildren.length <= fElementChildrenLength) {
        QName[] newarray = new QName[fElementChildren.length * 2];
        System.arraycopy(fElementChildren, 0, newarray, 0, fElementChildren.length);
        fElementChildren = newarray;
    }
    QName qname = fElementChildren[fElementChildrenLength];
    if (qname == null) {
        for (int i = fElementChildrenLength; i < fElementChildren.length; i++) {
            fElementChildren[i] = new QName();
        }
        qname = fElementChildren[fElementChildrenLength];
    }
    qname.clear();
    fElementChildrenLength++;

}
 
Example #15
Source File: XSEmptyCM.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
/**
 * The method corresponds to one transaction in the content model.
 *
 * @param elementName the qualified name of the element
 * @param currentState Current state
 * @param subGroupHandler the substitution group handler
 * @return element index corresponding to the element from the Schema grammar
 */
public Object oneTransition (QName elementName, int[] currentState, SubstitutionGroupHandler subGroupHandler){

    // error state
    if (currentState[0] < 0) {
        currentState[0] = XSCMValidator.SUBSEQUENT_ERROR;
        return null;
    }

    currentState[0] = XSCMValidator.FIRST_ERROR;
    return null;
}
 
Example #16
Source File: DTDGrammar.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private void ensureAttributeDeclCapacity(int chunk) {

        if (chunk >= fAttributeDeclName.length) {
            fAttributeDeclIsExternal = resize(fAttributeDeclIsExternal,
                                       fAttributeDeclIsExternal.length * 2);
            fAttributeDeclName = resize(fAttributeDeclName, fAttributeDeclName.length * 2);
            fAttributeDeclType = resize(fAttributeDeclType, fAttributeDeclType.length * 2);
            fAttributeDeclEnumeration = resize(fAttributeDeclEnumeration, fAttributeDeclEnumeration.length * 2);
            fAttributeDeclDefaultType = resize(fAttributeDeclDefaultType, fAttributeDeclDefaultType.length * 2);
            fAttributeDeclDatatypeValidator = resize(fAttributeDeclDatatypeValidator, fAttributeDeclDatatypeValidator.length * 2);
            fAttributeDeclDefaultValue = resize(fAttributeDeclDefaultValue, fAttributeDeclDefaultValue.length * 2);
            fAttributeDeclNonNormalizedDefaultValue = resize(fAttributeDeclNonNormalizedDefaultValue, fAttributeDeclNonNormalizedDefaultValue.length * 2);
            fAttributeDeclNextAttributeDeclIndex = resize(fAttributeDeclNextAttributeDeclIndex, fAttributeDeclNextAttributeDeclIndex.length * 2);
        }
        else if (fAttributeDeclName[chunk] != null) {
            return;
        }

        fAttributeDeclIsExternal[chunk] = new int[CHUNK_SIZE];
        fAttributeDeclName[chunk] = new QName[CHUNK_SIZE];
        fAttributeDeclType[chunk] = new short[CHUNK_SIZE];
        fAttributeDeclEnumeration[chunk] = new String[CHUNK_SIZE][];
        fAttributeDeclDefaultType[chunk] = new short[CHUNK_SIZE];
        fAttributeDeclDatatypeValidator[chunk] = new DatatypeValidator[CHUNK_SIZE];
        fAttributeDeclDefaultValue[chunk] = new String[CHUNK_SIZE];
        fAttributeDeclNonNormalizedDefaultValue[chunk] = new String[CHUNK_SIZE];
        fAttributeDeclNextAttributeDeclIndex[chunk] = new int[CHUNK_SIZE];
        return;
    }
 
Example #17
Source File: XMLDTDValidator.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * The start of an element.
 *
 * @param element    The name of the element.
 * @param attributes The element attributes.
 * @param augs   Additional information that may include infoset augmentations
 *
 * @throws XNIException Thrown by handler to signal an error.
 */
public void startElement(QName element, XMLAttributes attributes, Augmentations augs)
throws XNIException {

    handleStartElement(element, attributes, augs);
    // call handlers
    if (fDocumentHandler != null) {
        fDocumentHandler.startElement(element, attributes, augs);

    }

}
 
Example #18
Source File: CMLeaf.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/** Constructs a content model leaf. */
public CMLeaf(QName element)  {
    super(XMLContentSpec.CONTENTSPECNODE_LEAF);

    // Store the element index and position
    fElement.setValues(element);
}
 
Example #19
Source File: XMLDTDValidator.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
protected void endNamespaceScope(QName element,  Augmentations augs, boolean isEmpty){

        // call handlers
        if (fDocumentHandler != null && !isEmpty) {
            // NOTE: The binding of the element doesn't actually happen
            //       yet because the namespace binder does that. However,
            //       if it does it before this point, then the endPrefix-
            //       Mapping calls get made too soon! As long as the
            //       rawnames match, we know it'll have a good binding,
            //       so we can just use the current element. -Ac
            fDocumentHandler.endElement(fCurrentElement, augs);
        }
    }
 
Example #20
Source File: DTDGrammar.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
protected int createElementDecl() {
   int chunk = fElementDeclCount >> CHUNK_SHIFT;
   int index = fElementDeclCount & CHUNK_MASK;
   ensureElementDeclCapacity(chunk);
   fElementDeclName[chunk][index]                    = new QName();
   fElementDeclType[chunk][index]                    = -1;
   fElementDeclContentModelValidator[chunk][index]   = null;
   fElementDeclFirstAttributeDeclIndex[chunk][index] = -1;
   fElementDeclLastAttributeDeclIndex[chunk][index]  = -1;
   return fElementDeclCount++;
}
 
Example #21
Source File: DTDGrammar.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns whether the given attribute is of type CDATA or not
 *
 * @param elName The element name.
 * @param atName The attribute name.
 *
 * @return true if the attribute is of type CDATA
 */
public boolean isCDATAAttribute(QName elName, QName atName) {
    int elDeclIdx = getElementDeclIndex(elName);
    if (getAttributeDecl(elDeclIdx, fAttributeDecl)
        && fAttributeDecl.simpleType.type != XMLSimpleType.TYPE_CDATA){
        return false;
    }
    return true;
}
 
Example #22
Source File: ShortHandPointer.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public boolean resolveXPointer(QName element, XMLAttributes attributes,
        Augmentations augs, int event) throws XNIException {

    // reset fIsFragmentResolved
    if (fMatchingChildCount == 0) {
        fIsFragmentResolved = false;
    }

    // On startElement or emptyElement, if no matching elements or parent
    // elements were found, check for a matching idenfitier.
    if (event == XPointerPart.EVENT_ELEMENT_START) {
        if (fMatchingChildCount == 0) {
            fIsFragmentResolved = hasMatchingIdentifier(element, attributes, augs,
                event);
        }
        if (fIsFragmentResolved) {
           fMatchingChildCount++;
        }
    } else if (event == XPointerPart.EVENT_ELEMENT_EMPTY) {
        if (fMatchingChildCount == 0) {
            fIsFragmentResolved = hasMatchingIdentifier(element, attributes, augs,
                event);
        }
    }
    else {
        // On endElement, decrease the matching child count if the child or
        // its parent was resolved.
        if (fIsFragmentResolved) {
            fMatchingChildCount--;
        }
    }

    return fIsFragmentResolved ;
}
 
Example #23
Source File: StAXSchemaParser.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
/** Fills in a QName object. */
final void fillQName(QName toFill, String uri, String localpart, String prefix) {
    uri = (uri != null && uri.length() > 0) ? fSymbolTable.addSymbol(uri) : null;
    localpart = (localpart != null) ? fSymbolTable.addSymbol(localpart) : XMLSymbols.EMPTY_STRING;
    prefix = (prefix != null && prefix.length() > 0) ? fSymbolTable.addSymbol(prefix) : XMLSymbols.EMPTY_STRING;
    String raw = localpart;
    if (prefix != XMLSymbols.EMPTY_STRING) {
        fStringBuffer.clear();
        fStringBuffer.append(prefix);
        fStringBuffer.append(':');
        fStringBuffer.append(localpart);
        raw = fSymbolTable.addSymbol(fStringBuffer.ch, fStringBuffer.offset, fStringBuffer.length);
    }
    toFill.setValues(prefix, localpart, raw, uri);
}
 
Example #24
Source File: XMLAttributesImpl.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
/**
 * Adds an attribute. The attribute's non-normalized value of the
 * attribute will have the same value as the attribute value until
 * set using the <code>setNonNormalizedValue</code> method. Also,
 * the added attribute will be marked as specified in the XML instance
 * document unless set otherwise using the <code>setSpecified</code>
 * method.
 * <p>
 * This method differs from <code>addAttribute</code> in that it
 * does not check if an attribute of the same name already exists
 * in the list before adding it. In order to improve performance
 * of namespace processing, this method allows uniqueness checks
 * to be deferred until all the namespace information is available
 * after the entire attribute specification has been read.
 * <p>
 * <strong>Caution:</strong> If this method is called it should
 * not be mixed with calls to <code>addAttribute</code> unless
 * it has been determined that all the attribute names are unique.
 *
 * @param name the attribute name
 * @param type the attribute type
 * @param value the attribute value
 *
 * @see #setNonNormalizedValue
 * @see #setSpecified
 * @see #checkDuplicatesNS
 */
public void addAttributeNS(QName name, String type, String value) {
    int index = fLength;
    if (fLength++ == fAttributes.length) {
        Attribute[] attributes;
        if (fLength < SIZE_LIMIT) {
            attributes = new Attribute[fAttributes.length + 4];
        }
        else {
            attributes = new Attribute[fAttributes.length << 1];
        }
        System.arraycopy(fAttributes, 0, attributes, 0, fAttributes.length);
        for (int i = fAttributes.length; i < attributes.length; i++) {
            attributes[i] = new Attribute();
        }
        fAttributes = attributes;
    }

    // set values
    Attribute attribute = fAttributes[index];
    attribute.name.setValues(name);
    attribute.type = type;
    attribute.value = value;
    attribute.nonNormalizedValue = value;
    attribute.specified = false;

    // clear augmentations
    attribute.augs.removeAllItems();
}
 
Example #25
Source File: XSAllCM.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * The method corresponds to one transition in the content model.
 *
 * @param elementName
 * @param currentState  Current state
 * @return an element decl object
 */
public Object oneTransition (QName elementName, int[] currentState, SubstitutionGroupHandler subGroupHandler) {

    // error state
    if (currentState[0] < 0) {
        currentState[0] = XSCMValidator.SUBSEQUENT_ERROR;
        return findMatchingDecl(elementName, subGroupHandler);
    }

    // seen child
    currentState[0] = STATE_CHILD;

    Object matchingDecl = null;

    for (int i = 0; i < fNumElements; i++) {
        // we only try to look for a matching decl if we have not seen
        // this element yet.
        if (currentState[i+1] != STATE_START)
            continue;
        matchingDecl = subGroupHandler.getMatchingElemDecl(elementName, fAllElements[i]);
        if (matchingDecl != null) {
            // found the decl, mark this element as "seen".
            currentState[i+1] = STATE_VALID;
            return matchingDecl;
        }
    }

    // couldn't find the decl, change to error state.
    currentState[0] = XSCMValidator.FIRST_ERROR;
    return findMatchingDecl(elementName, subGroupHandler);
}
 
Example #26
Source File: StAXSchemaParser.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/** Fills in a QName object. */
final void fillQName(QName toFill, String uri, String localpart, String prefix) {
    uri = (uri != null && uri.length() > 0) ? fSymbolTable.addSymbol(uri) : null;
    localpart = (localpart != null) ? fSymbolTable.addSymbol(localpart) : XMLSymbols.EMPTY_STRING;
    prefix = (prefix != null && prefix.length() > 0) ? fSymbolTable.addSymbol(prefix) : XMLSymbols.EMPTY_STRING;
    String raw = localpart;
    if (prefix != XMLSymbols.EMPTY_STRING) {
        fStringBuffer.clear();
        fStringBuffer.append(prefix);
        fStringBuffer.append(':');
        fStringBuffer.append(localpart);
        raw = fSymbolTable.addSymbol(fStringBuffer.ch, fStringBuffer.offset, fStringBuffer.length);
    }
    toFill.setValues(prefix, localpart, raw, uri);
}
 
Example #27
Source File: XMLSchemaValidator.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
/**
 * The start of an element.
 *
 * @param element    The name of the element.
 * @param attributes The element attributes.
 * @param augs     Additional information that may include infoset augmentations
 *
 * @throws XNIException Thrown by handler to signal an error.
 */
public void startElement(QName element, XMLAttributes attributes, Augmentations augs)
    throws XNIException {

    Augmentations modifiedAugs = handleStartElement(element, attributes, augs);
    // call handlers
    if (fDocumentHandler != null) {
        fDocumentHandler.startElement(element, attributes, modifiedAugs);
    }

}
 
Example #28
Source File: XPath.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Used by {@link #parseExpression} to parse a node test
 * from the token list.
 */
private NodeTest parseNodeTest( int typeToken, Tokens xtokens, NamespaceContext context )
    throws XPathException {
    switch(typeToken) {
    case XPath.Tokens.EXPRTOKEN_NAMETEST_ANY:
        return new NodeTest(NodeTest.WILDCARD);

    case XPath.Tokens.EXPRTOKEN_NAMETEST_NAMESPACE:
    case XPath.Tokens.EXPRTOKEN_NAMETEST_QNAME:
        // consume QName token
        String prefix = xtokens.nextTokenAsString();
        String uri = null;
        if (context != null && prefix != XMLSymbols.EMPTY_STRING) {
            uri = context.getURI(prefix);
        }
        if (prefix != XMLSymbols.EMPTY_STRING && context != null && uri == null) {
            throw new XPathException("c-general-xpath-ns");
        }

        if (typeToken==XPath.Tokens.EXPRTOKEN_NAMETEST_NAMESPACE)
            return new NodeTest(prefix,uri);

        String localpart = xtokens.nextTokenAsString();
        String rawname = prefix != XMLSymbols.EMPTY_STRING
        ? fSymbolTable.addSymbol(prefix+':'+localpart)
        : localpart;

        return new NodeTest(new QName(prefix, localpart, rawname, uri));

    default:
        // assertion error
        throw new XPathException("c-general-xpath");

    }
}
 
Example #29
Source File: QNameDV.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/** Returns true if the two objects are equal. */
public boolean equals(Object object) {
    if (object instanceof QName) {
        QName qname = (QName)object;
        return uri == qname.uri && localpart == qname.localpart;
    }
    return false;
}
 
Example #30
Source File: DTDGrammar.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
protected int createElementDecl() {
    int chunk = fElementDeclCount >> CHUNK_SHIFT;
    int index = fElementDeclCount & CHUNK_MASK;
    ensureElementDeclCapacity(chunk);
    fElementDeclName[chunk][index]                    = new QName();
    fElementDeclType[chunk][index]                    = -1;
    fElementDeclFirstAttributeDeclIndex[chunk][index] = -1;
    fElementDeclLastAttributeDeclIndex[chunk][index]  = -1;
    return fElementDeclCount++;
}