Java源码示例:com.sun.org.apache.xerces.internal.xni.XMLAttributes

示例1
/**
 * An empty element.
 *
 * @param element    The name of the element.
 * @param attributes The element attributes.
 * @param augs       Additional information that may include infoset augmentations
 *
 * @exception XNIException
 *                   Thrown by handler to signal an error.
 */
public void emptyElement(QName element, XMLAttributes attributes,
        Augmentations augs) throws XNIException {
    if (!resolveXPointer(element, attributes, augs,
            XPointerPart.EVENT_ELEMENT_EMPTY)) {
        // xml:base and xml:lang processing
            if (fFixupBase) {
            processXMLBaseAttributes(attributes);
            }
        if (fFixupLang) {
            processXMLLangAttributes(attributes);
        }
        // no need to restore restoreBaseURI() for xml:base and xml:lang processing

        // set the context invalid if the element till an element from the result infoset is included
        fNamespaceContext.setContextInvalid();
        return;
    }
    super.emptyElement(element, attributes, augs);
}
 
示例2
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();
        }
    }
}
 
示例3
/** Handle element
 * @return true if validator is removed from the pipeline
 */
protected void handleStartElement(QName element, XMLAttributes attributes) throws XNIException {

    if (fDTDGrammar == null) {
        fCurrentElementIndex = -1;
        fCurrentContentSpecType = -1;
        fInElementContent = false;
        return;
    } else {
        fCurrentElementIndex = fDTDGrammar.getElementDeclIndex(element);
        fCurrentContentSpecType = fDTDGrammar.getContentSpecType(
                fCurrentElementIndex);
        //handleDTDDefaultAttrs(element,attributes);
        addDTDDefaultAttrs(element, attributes);
    }

    fInElementContent = fCurrentContentSpecType == XMLElementDecl.TYPE_CHILDREN;
    fElementDepth++;
    ensureStackCapacity(fElementDepth);
    fElementContentState[fElementDepth] = fInElementContent;
}
 
示例4
/**
 * An empty element.
 *
 * @param element    The name of the element.
 * @param attributes The element attributes.
 * @param augs       Additional information that may include infoset augmentations
 *
 * @exception XNIException
 *                   Thrown by handler to signal an error.
 */
public void emptyElement(QName element, XMLAttributes attributes,
        Augmentations augs) throws XNIException {
    if (!resolveXPointer(element, attributes, augs,
            XPointerPart.EVENT_ELEMENT_EMPTY)) {
        // xml:base and xml:lang processing
            if (fFixupBase) {
            processXMLBaseAttributes(attributes);
            }
        if (fFixupLang) {
            processXMLLangAttributes(attributes);
        }
        // no need to restore restoreBaseURI() for xml:base and xml:lang processing

        // set the context invalid if the element till an element from the result infoset is included
        fNamespaceContext.setContextInvalid();
        return;
    }
    super.emptyElement(element, attributes, augs);
}
 
示例5
/**
         * The start of an element. If the document specifies the start element
         * by using an empty tag, then the startElement method will immediately
         * be followed by the endElement method, with no intervening methods.
         *
         * @param element    The name of the element.
         * @param attributes The element attributes.
         *
         */
        public void startElement(QName element, XMLAttributes attributes) {
            super.startElement(element, attributes);
            fElementDepth++;
            // activate the fields, if selector is matched
            //int matched = isMatched();

            if (isMatched()) {
/*            (fMatchedDepth == -1 && ((matched & MATCHED) == MATCHED)) ||
                    ((matched & MATCHED_DESCENDANT) == MATCHED_DESCENDANT)) { */
                fMatchedDepth = fElementDepth;
                fFieldActivator.startValueScopeFor(fIdentityConstraint, fInitialDepth);
                int count = fIdentityConstraint.getFieldCount();
                for (int i = 0; i < count; i++) {
                    Field field = fIdentityConstraint.getFieldAt(i);
                    XPathMatcher matcher = fFieldActivator.activateField(field, fInitialDepth);
                    matcher.startElement(element, attributes);
                }
            }

        }
 
示例6
/**
         * The start of an element. If the document specifies the start element
         * by using an empty tag, then the startElement method will immediately
         * be followed by the endElement method, with no intervening methods.
         *
         * @param element    The name of the element.
         * @param attributes The element attributes.
         *
         */
        public void startElement(QName element, XMLAttributes attributes) {
            super.startElement(element, attributes);
            fElementDepth++;
            // activate the fields, if selector is matched
            //int matched = isMatched();

            if (isMatched()) {
/*            (fMatchedDepth == -1 && ((matched & MATCHED) == MATCHED)) ||
                    ((matched & MATCHED_DESCENDANT) == MATCHED_DESCENDANT)) { */
                fMatchedDepth = fElementDepth;
                fFieldActivator.startValueScopeFor(fIdentityConstraint, fInitialDepth);
                int count = fIdentityConstraint.getFieldCount();
                for (int i = 0; i < count; i++) {
                    Field field = fIdentityConstraint.getFieldAt(i);
                    XPathMatcher matcher = fFieldActivator.activateField(field, fInitialDepth);
                    matcher.startElement(element, attributes);
                }
            }

        }
 
示例7
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();
        }
    }
}
 
示例8
/**
 * 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
        }
    }
}
 
示例9
/**
 * 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 {

    if (fNamespaces) {
        handleStartElement(element, attributes, augs, true);
        handleEndElement(element, augs, true);
    }
    else if (fDocumentHandler != null) {
        fDocumentHandler.emptyElement(element, attributes, augs);
    }

}
 
示例10
/**
 * 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);
    }

}
 
示例11
/**
 * The start of an element. If the document specifies the start element
 * by using an empty tag, then the startElement method will immediately
 * be followed by the endElement method, with no intervening methods.
 * Overriding the parent to handle DOM_NAMESPACE_DECLARATIONS=false.
 *
 * @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) {
    // namespace declarations parameter has no effect if namespaces is false.
    if (!fNamespaceDeclarations && fNamespaceAware) {
        int len = attributes.getLength();
        for (int i = len - 1; i >= 0; --i) {
            if (XMLSymbols.PREFIX_XMLNS == attributes.getPrefix(i) ||
                XMLSymbols.PREFIX_XMLNS == attributes.getQName(i)) {
                attributes.removeAttributeAt(i);
            }
        }
    }
    super.startElement(element, attributes, augs);
}
 
示例12
/**
 * Responsible for resolving the element() scheme XPointer.  If a ShortHand
 * Pointer is present and it is successfully resolved and if a child
 * sequence is present, the child sequence is resolved relative to it.
 *
 * @see com.sun.org.apache.xerces.internal.xpointer.XPointerProcessor#resolveXPointer(com.sun.org.apache.xerces.internal.xni.QName, com.sun.org.apache.xerces.internal.xni.XMLAttributes, com.sun.org.apache.xerces.internal.xni.Augmentations, int event)
 */
public boolean resolveXPointer(QName element, XMLAttributes attributes,
        Augmentations augs, int event) throws XNIException {

    boolean isShortHandPointerResolved = false;

    // if a ChildSequence exisits, resolve child elements

    // if an element name exists
    if (fShortHandPointerName != null) {
        // resolve ShortHand Pointer
        isShortHandPointerResolved = fShortHandPointer.resolveXPointer(
                element, attributes, augs, event);
        if (isShortHandPointerResolved) {
            fIsResolveElement = true;
            fIsShortHand = true;
        } else {
            fIsResolveElement = false;
        }
    } else {
        fIsResolveElement = true;
    }

    // Added here to skip the ShortHand pointer corresponding to
    // an element if one exisits and start searching from its child
    if (fChildSequence.length > 0) {
        fIsFragmentResolved = matchChildSequence(element, event);
    } else if (isShortHandPointerResolved && fChildSequence.length <= 0) {
        // if only a resolved shorthand pointer exists
        fIsFragmentResolved = isShortHandPointerResolved;
    } else {
        fIsFragmentResolved = false;
    }

    return fIsFragmentResolved;
}
 
示例13
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(">");
}
 
示例14
/**
 * 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);

    }

}
 
示例15
/**
 * 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);
    }

}
 
示例16
/**
 * @param attributes
 * @return
 */
private boolean hasNonSchemaAttributes(QName element, XMLAttributes attributes) {
    final int length = attributes.getLength();
    for (int i = 0; i < length; ++i) {
        String uri = attributes.getURI(i);
        if (uri != null && uri != SchemaSymbols.URI_SCHEMAFORSCHEMA &&
                uri != NamespaceContext.XMLNS_URI &&
                !(uri == NamespaceContext.XML_URI &&
                        attributes.getQName(i) == SchemaSymbols.ATT_XML_LANG && element.localpart == SchemaSymbols.ELT_SCHEMA)) {
            return true;
        }
    }
    return false;
}
 
示例17
/**
 * 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 {

    if (fNamespaces) {
        handleStartElement(element, attributes, augs, true);
        handleEndElement(element, augs, true);
    }
    else if (fDocumentHandler != null) {
        fDocumentHandler.emptyElement(element, attributes, augs);
    }

}
 
示例18
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 ;
}
 
示例19
/**
 * 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;
}
 
示例20
/**
 * 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);
    }

}
 
示例21
/**
 * Returns the schema-determined-ID.
 *
 *
 * @param attributes
 * @param index
 * @return A String containing the schema-determined ID.
 * @throws XNIException
 */
public String getSchemaDeterminedID(XMLAttributes attributes, int index)
throws XNIException {
    Augmentations augs = attributes.getAugmentations(index);
    AttributePSVI attrPSVI = (AttributePSVI) augs
    .getItem(Constants.ATTRIBUTE_PSVI);

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

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

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

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

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

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

        // 4 & 5 NA
    }

    return null;
}
 
示例22
/**
 * 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);
    }

}
 
示例23
/**
 * 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);
    }

}
 
示例24
/**
 * 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;
}
 
示例25
/**
 * Returns the schema-determined-ID.
 *
 *
 * @param attributes
 * @param index
 * @return A String containing the schema-determined ID.
 * @throws XNIException
 */
public String getSchemaDeterminedID(XMLAttributes attributes, int index)
throws XNIException {
    Augmentations augs = attributes.getAugmentations(index);
    AttributePSVI attrPSVI = (AttributePSVI) augs
    .getItem(Constants.ATTRIBUTE_PSVI);

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

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

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

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

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

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

        // 4 & 5 NA
    }

    return null;
}
 
示例26
/**
 * 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);
    }

}
 
示例27
public ElementImpl startElement(QName element, XMLAttributes attributes,
        int line, int column, int offset) {
    ElementImpl node = new ElementImpl(line, column, offset);
    processElement(element, attributes, node);
    // now the current node added, becomes the parent
    parent = node;
    return node;
}
 
示例28
public void startElement(QName element, XMLAttributes attributes, Augmentations augs) throws XNIException {
    side.startElement(element, attributes, augs);
    next.startElement(element, attributes, augs);
}
 
示例29
private boolean isIdAttribute(XMLAttributes attributes,Augmentations augs, int index) {
    Object o = augs.getItem(Constants.ID_ATTRIBUTE);
    if( o instanceof Boolean )
        return ((Boolean)o).booleanValue();
    return "ID".equals(attributes.getType(index));
}
 
示例30
@Override
public void emptyElement(
    QName element,
    XMLAttributes attributes,
    Augmentations augs)
    throws XNIException {
    fDepth++;
    int lastState = getState(fDepth - 1);
    // If the last two states were fallback then this must be a descendant of an include
    // child which isn't a fallback. The specification says we should ignore such elements
    // and their children.
    if (lastState == STATE_EXPECT_FALLBACK && getState(fDepth - 2) == STATE_EXPECT_FALLBACK) {
        setState(STATE_IGNORE);
    }
    else {
        setState(lastState);
    }

    // we process the xml:base and xml:lang attributes regardless
    // of what type of element it is.
    processXMLBaseAttributes(attributes);
    if (fFixupLanguage) {
        processXMLLangAttributes(attributes);
    }

    if (isIncludeElement(element)) {
        boolean success = this.handleIncludeElement(attributes);
        if (success) {
            setState(STATE_IGNORE);
        }
        else {
            reportFatalError("NoFallback",
                new Object[] { attributes.getValue(null, "href") });
        }
    }
    else if (isFallbackElement(element)) {
        this.handleFallbackElement();
    }
    else if (hasXIncludeNamespace(element)) {
        if (getSawInclude(fDepth - 1)) {
            reportFatalError(
                "IncludeChild",
                new Object[] { element.rawname });
        }
        if (getSawFallback(fDepth - 1)) {
            reportFatalError(
                "FallbackChild",
                new Object[] { element.rawname });
        }
        if (getState() == STATE_NORMAL_PROCESSING) {
            if (fResultDepth == 0) {
                checkMultipleRootElements();
            }
            if (fDocumentHandler != null) {
                augs = modifyAugmentations(augs);
                attributes = processAttributes(attributes);
                fDocumentHandler.emptyElement(element, attributes, augs);
            }
        }
    }
    else if (getState() == STATE_NORMAL_PROCESSING) {
        if (fResultDepth == 0) {
            checkMultipleRootElements();
        }
        if (fDocumentHandler != null) {
            augs = modifyAugmentations(augs);
            attributes = processAttributes(attributes);
            fDocumentHandler.emptyElement(element, attributes, augs);
        }
    }
    // reset the out of scope stack elements
    setSawFallback(fDepth + 1, false);
    setSawInclude(fDepth, false);

    // check if an xml:base has gone out of scope
    if (fBaseURIScope.size() > 0 && fDepth == fBaseURIScope.peek()) {
        // pop the values from the stack
        restoreBaseURI();
    }
    fDepth--;
}