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

The following examples show how to use com.sun.org.apache.xerces.internal.xni.XNIException. 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: XMLDTDProcessor.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * This method notifies of the start of a parameter entity. The parameter
 * entity name start with a '%' character.
 *
 * @param name     The name of the parameter entity.
 * @param identifier The resource identifier.
 * @param encoding The auto-detected IANA encoding name of the entity
 *                 stream. This value will be null in those situations
 *                 where the entity encoding is not auto-detected (e.g.
 *                 internal parameter entities).
 * @param augs Additional information that may include infoset
 *                      augmentations.
 *
 * @throws XNIException Thrown by handler to signal an error.
 */
public void startParameterEntity(String name,
                                 XMLResourceIdentifier identifier,
                                 String encoding,
                                 Augmentations augs) throws XNIException {

    if (fPerformValidation && fDTDGrammar != null &&
            fGrammarBucket.getStandalone()) {
        checkStandaloneEntityRef(name, fDTDGrammar, fEntityDecl, fErrorReporter);
    }
    // call handlers
    if(fDTDGrammar != null )
        fDTDGrammar.startParameterEntity(name, identifier, encoding, augs);
    if (fDTDHandler != null) {
        fDTDHandler.startParameterEntity(name, identifier, encoding, augs);
    }
}
 
Example #2
Source File: AbstractDOMParser.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
/**
 * Notifies of the presence of an XMLDecl line in the document. If
 * present, this method will be called immediately following the
 * startDocument call.
 *
 * @param version    The XML version.
 * @param encoding   The IANA encoding name of the document, or null if
 *                   not specified.
 * @param standalone The standalone value, or null if not specified.
 * @param augs       Additional information that may include infoset augmentations
 *
 * @throws XNIException Thrown by handler to signal an error.
 */
public void xmlDecl (String version, String encoding, String standalone,
Augmentations augs)
throws XNIException {
    if (!fDeferNodeExpansion) {
        // REVISIT: when DOM Level 3 is REC rely on Document.support
        //          instead of specific class
        if (fDocumentImpl != null) {
            if (version != null)
                fDocumentImpl.setXmlVersion (version);
            fDocumentImpl.setXmlEncoding (encoding);
            fDocumentImpl.setXmlStandalone ("yes".equals (standalone));
        }
    }
    else {
        if (version != null)
            fDeferredDocumentImpl.setXmlVersion (version);
        fDeferredDocumentImpl.setXmlEncoding (encoding);
        fDeferredDocumentImpl.setXmlStandalone ("yes".equals (standalone));
    }
}
 
Example #3
Source File: XMLDTDProcessor.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
/**
 * The start of a content model. Depending on the type of the content
 * model, specific methods may be called between the call to the
 * startContentModel method and the call to the endContentModel method.
 *
 * @param elementName The name of the element.
 * @param augs Additional information that may include infoset
 *                      augmentations.
 *
 * @throws XNIException Thrown by handler to signal an error.
 */
public void startContentModel(String elementName, Augmentations augs)
    throws XNIException {

    if (fValidation) {
        fDTDElementDeclName = elementName;
        fMixedElementTypes.clear();
    }

    // call handlers
    if(fDTDGrammar != null)
        fDTDGrammar.startContentModel(elementName, augs);
    if (fDTDContentModelHandler != null) {
        fDTDContentModelHandler.startContentModel(elementName, augs);
    }

}
 
Example #4
Source File: XPointerHandler.java    From openjdk-jdk8u with GNU General Public License v2.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
 *
 * @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);
}
 
Example #5
Source File: XMLDTDProcessor.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * An unparsed entity declaration.
 *
 * @param name     The name of the entity.
 * @param identifier    An object containing all location information
 *                      pertinent to this entity.
 * @param notation The name of the notation.
 * @param augs Additional information that may include infoset
 *                      augmentations.
 *
 * @throws XNIException Thrown by handler to signal an error.
 */
public void unparsedEntityDecl(String name, XMLResourceIdentifier identifier,
                               String notation,
                               Augmentations augs) throws XNIException {

    // VC: Notation declared,  in the production of NDataDecl
    if (fValidation) {
        fNDataDeclNotations.put(name, notation);
    }

    // call handlers
    if(fDTDGrammar != null)
        fDTDGrammar.unparsedEntityDecl(name, identifier, notation, augs);
    if (fDTDHandler != null) {
        fDTDHandler.unparsedEntityDecl(name, identifier, notation, augs);
    }

}
 
Example #6
Source File: XMLDTDValidator.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * A processing instruction. Processing instructions consist of a
 * target name and, optionally, text data. The data is only meaningful
 * to the application.
 * <p>
 * Typically, a processing instruction's data will contain a series
 * of pseudo-attributes. These pseudo-attributes follow the form of
 * element attributes but are <strong>not</strong> parsed or presented
 * to the application as anything other than text. The application is
 * responsible for parsing the data.
 *
 * @param target The target.
 * @param data   The data or null if none specified.
 * @param augs   Additional information that may include infoset augmentations
 *
 * @throws XNIException Thrown by handler to signal an error.
 */
public void processingInstruction(String target, XMLString data, Augmentations augs)
throws XNIException {

    // fixes E15.1
    if (fPerformValidation && fElementDepth >= 0 && fDTDGrammar != null) {
        fDTDGrammar.getElementDecl(fCurrentElementIndex, fTempElementDecl);
        if (fTempElementDecl.type == XMLElementDecl.TYPE_EMPTY) {
                fErrorReporter.reportError(XMLMessageFormatter.XML_DOMAIN,
                                           "MSG_CONTENT_INVALID_SPECIFIED",
                                           new Object[]{ fCurrentElement.rawname,
                                                         "EMPTY",
                                                         "processing instruction"},
                                           XMLErrorReporter.SEVERITY_ERROR);
        }
    }
    // call handlers
    if (fDocumentHandler != null) {
        fDocumentHandler.processingInstruction(target, data, augs);
    }
}
 
Example #7
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 #8
Source File: XMLDocumentScannerImpl.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public int next() throws IOException, XNIException{
    // throw new XNIException("DTD Parsing is currently not supported");
    if(DEBUG_NEXT){
        System.out.println("Now in DTD Driver");
    }

    dispatch(true);

    if(DEBUG_NEXT){
        System.out.println("After calling dispatch(true) -- At this point whole DTD is read.");
    }

    //xxx: remove this hack and align this with reusing DTD components
    //currently this routine will only be executed from Stax
    if(fPropertyManager != null){
        dtdGrammarUtil =  new DTDGrammarUtil(((XMLDTDScannerImpl)fDTDScanner).getGrammar(),fSymbolTable, fNamespaceContext);
    }

    return XMLEvent.DTD ;
}
 
Example #9
Source File: XMLDTDValidator.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * A comment.
 *
 * @param text The text in the comment.
 * @param augs   Additional information that may include infoset augmentations
 *
 * @throws XNIException Thrown by application to signal an error.
 */
public void comment(XMLString text, Augmentations augs) throws XNIException {
    // fixes E15.1
    if (fPerformValidation && fElementDepth >= 0 && fDTDGrammar != null) {
        fDTDGrammar.getElementDecl(fCurrentElementIndex, fTempElementDecl);
        if (fTempElementDecl.type == XMLElementDecl.TYPE_EMPTY) {
                fErrorReporter.reportError(XMLMessageFormatter.XML_DOMAIN,
                                           "MSG_CONTENT_INVALID_SPECIFIED",
                                           new Object[]{ fCurrentElement.rawname,
                                                         "EMPTY",
                                                         "comment"},
                                           XMLErrorReporter.SEVERITY_ERROR);
        }
    }
    // call handlers
    if (fDocumentHandler != null) {
        fDocumentHandler.comment(text, augs);
    }

}
 
Example #10
Source File: XMLScanner.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Scans the name of a pseudo attribute. The only legal names
 * in XML 1.0/1.1 documents are 'version', 'encoding' and 'standalone'.
 *
 * @return the name of the pseudo attribute or <code>null</code>
 * if a legal pseudo attribute name could not be scanned.
 */
private String scanPseudoAttributeName() throws IOException, XNIException {
    final int ch = fEntityScanner.peekChar();
    switch (ch) {
        case 'v':
            if (fEntityScanner.skipString(fVersionSymbol)) {
                return fVersionSymbol;
            }
            break;
        case 'e':
            if (fEntityScanner.skipString(fEncodingSymbol)) {
                return fEncodingSymbol;
            }
            break;
        case 's':
            if (fEntityScanner.skipString(fStandaloneSymbol)) {
                return fStandaloneSymbol;
            }
            break;
    }
    return null;
}
 
Example #11
Source File: XMLDTDScannerImpl.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * start a parameter entity dealing with the textdecl if there is any
 *
 * @param name The name of the parameter entity to start (without the '%')
 * @param literal Whether this is happening within a literal
 */
protected void startPE(String name, boolean literal)
throws IOException, XNIException {
    int depth = fPEDepth;
    String pName = "%"+name;
    if (fValidation && !fEntityStore.isDeclaredEntity(pName)) {
        fErrorReporter.reportError( XMLMessageFormatter.XML_DOMAIN,"EntityNotDeclared",
        new Object[]{name}, XMLErrorReporter.SEVERITY_ERROR);
    }
    fEntityManager.startEntity(false, fSymbolTable.addSymbol(pName),
    literal);
    // if we actually got a new entity and it's external
    // parse text decl if there is any
    if (depth != fPEDepth && fEntityScanner.isExternal()) {
        scanTextDecl();
    }
}
 
Example #12
Source File: JAXPValidatorComponent.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
public void processingInstruction(String target, XMLString data, Augmentations augs) throws XNIException {
    try {
        fContentHandler.processingInstruction(target,data.toString());
    } catch (SAXException e) {
        throw new XNIException(e);
    }
}
 
Example #13
Source File: DOMNormalizer.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
* The end of an element.
*
* @param element The name of the element.
* @param augs    Additional information that may include infoset augmentations
*
* @exception XNIException
*                   Thrown by handler to signal an error.
*/
   public void endElement(QName element, Augmentations augs) throws XNIException {
           if (DEBUG_EVENTS) {
                   System.out.println("==>endElement: " + element);
           }

   if(augs != null) {
           ElementPSVI elementPSVI = (ElementPSVI) augs.getItem(Constants.ELEMENT_PSVI);
           if (elementPSVI != null) {
                   ElementImpl elementNode = (ElementImpl) fCurrentNode;
                   if (fPSVI) {
                           ((PSVIElementNSImpl) fCurrentNode).setPSVI(elementPSVI);
                   }
                   // include element default content (if one is available)
                   String normalizedValue = elementPSVI.getSchemaNormalizedValue();
                   if ((fConfiguration.features & DOMConfigurationImpl.DTNORMALIZATION) != 0) {
               if (normalizedValue !=null)
                               elementNode.setTextContent(normalizedValue);
                   }
                   else {
                           // NOTE: this is a hack: it is possible that DOM had an empty element
                           // and validator sent default value using characters(), which we don't
                           // implement. Thus, here we attempt to add the default value.
                           String text = elementNode.getTextContent();
                           if (text.length() == 0) {
                                   // default content could be provided
                   if (normalizedValue !=null)
                       elementNode.setTextContent(normalizedValue);
                           }
                   }
           }
   }
   }
 
Example #14
Source File: XIncludeHandler.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
@Override
public void startAttlist(String elementName, Augmentations augmentations)
    throws XNIException {
    if (fDTDHandler != null) {
        fDTDHandler.startAttlist(elementName, augmentations);
    }
}
 
Example #15
Source File: XML11NSDocumentScannerImpl.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Scans the name of an element in a start or empty tag.
 *
 * @see #scanStartElement()
 */
protected void scanStartElementName ()
    throws IOException, XNIException {
    // Note: namespace processing is on by default
    fEntityScanner.scanQName(fElementQName);
    // Must skip spaces here because the DTD scanner
    // would consume them at the end of the external subset.
    fSawSpace = fEntityScanner.skipSpaces();
}
 
Example #16
Source File: XMLSchemaValidator.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
* The start of a CDATA section.
*
* @param augs     Additional information that may include infoset augmentations
*
* @throws XNIException Thrown by handler to signal an error.
*/
public void startCDATA(Augmentations augs) throws XNIException {

    // REVISIT: what should we do here if schema normalization is on??
    fInCDATA = true;
    // call handlers
    if (fDocumentHandler != null) {
        fDocumentHandler.startCDATA(augs);
    }

}
 
Example #17
Source File: ValidatorHandlerImpl.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public void startDocument(XMLLocator locator, String encoding,
        NamespaceContext namespaceContext, Augmentations augs)
        throws XNIException {
    if (fContentHandler != null) {
        try {
            fContentHandler.startDocument();
        }
        catch (SAXException e) {
            throw new XNIException(e);
        }
    }
}
 
Example #18
Source File: BasicParserConfiguration.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * reset all components before parsing and namespace context
 */
protected void reset() throws XNIException {

    // reset every component
    int count = fComponents.size();
    for (int i = 0; i < count; i++) {
        XMLComponent c = (XMLComponent) fComponents.get(i);
        c.reset(this);
    }

}
 
Example #19
Source File: XMLDocumentFilterImpl.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
public void startDocument(
    XMLLocator locator,
    String encoding,
    NamespaceContext namespaceContext,
    Augmentations augs)
    throws XNIException {
    next.startDocument(locator, encoding, namespaceContext, augs);
}
 
Example #20
Source File: ValidatorHandlerImpl.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
public void ignorableWhitespace(XMLString text, Augmentations augs)
        throws XNIException {
    if (fContentHandler != null) {
        try {
            fContentHandler.ignorableWhitespace(text.ch, text.offset, text.length);
        }
        catch (SAXException e) {
            throw new XNIException(e);
        }
    }
}
 
Example #21
Source File: XMLSchemaValidator.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * The end of a CDATA section.
 *
 * @param augs     Additional information that may include infoset augmentations
 *
 * @throws XNIException Thrown by handler to signal an error.
 */
public void endCDATA(Augmentations augs) throws XNIException {

    // call handlers
    fInCDATA = false;
    if (fDocumentHandler != null) {
        fDocumentHandler.endCDATA(augs);
    }

}
 
Example #22
Source File: XML11NonValidatingConfiguration.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * reset all common components before parsing
 */
protected void resetCommon() throws XNIException {
        // reset common components
        int count = fCommonComponents.size();
        for (int i = 0; i < count; i++) {
                XMLComponent c = (XMLComponent) fCommonComponents.get(i);
                c.reset(this);
        }

}
 
Example #23
Source File: XML11DTDConfiguration.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * reset all components before parsing and namespace context
 */
protected void resetXML11() throws XNIException {
        // reset every component
        int count = fXML11Components.size();
        for (int i = 0; i < count; i++) {
                XMLComponent c = (XMLComponent) fXML11Components.get(i);
                c.reset(this);
        }

}
 
Example #24
Source File: XMLDocumentScannerImpl.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Scan for DOCTYPE hook. This method is a hook for subclasses
 * to add code to handle scanning for a the "DOCTYPE" string
 * after the string "<!" has been scanned.
 *
 * @return True if the "DOCTYPE" was scanned; false if "DOCTYPE"
 *          was not scanned.
 */
protected boolean scanForDoctypeHook()
throws IOException, XNIException {

    if (fEntityScanner.skipString(DOCTYPE)) {
        setScannerState(SCANNER_STATE_DOCTYPE);
        //                fEntityScanner.markStartOfDTD();
        return true;
    }
    return false;

}
 
Example #25
Source File: XMLDTDProcessor.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * The start of an attribute list.
 *
 * @param elementName The name of the element that this attribute
 *                    list is associated with.
 * @param augs Additional information that may include infoset
 *                      augmentations.
 *
 * @throws XNIException Thrown by handler to signal an error.
 */
public void startAttlist(String elementName, Augmentations augs)
    throws XNIException {

    // call handlers
    if(fDTDGrammar != null )
        fDTDGrammar.startAttlist(elementName, augs);
    if (fDTDHandler != null) {
        fDTDHandler.startAttlist(elementName, augs);
    }

}
 
Example #26
Source File: AbstractSAXParser.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
/**
 * The start of the document.
 *
 * @param locator The document locator, or null if the document
 *                 location cannot be reported during the parsing
 *                 of this document. However, it is <em>strongly</em>
 *                 recommended that a locator be supplied that can
 *                 at least report the system identifier of the
 *                 document.
 * @param encoding The auto-detected IANA encoding name of the entity
 *                 stream. This value will be null in those situations
 *                 where the entity encoding is not auto-detected (e.g.
 *                 internal entities or a document entity that is
 *                 parsed from a java.io.Reader).
 * @param namespaceContext
 *                 The namespace context in effect at the
 *                 start of this document.
 *                 This object represents the current context.
 *                 Implementors of this class are responsible
 *                 for copying the namespace bindings from the
 *                 the current context (and its parent contexts)
 *                 if that information is important.
 * @param augs     Additional information that may include infoset augmentations
 *
 * @throws XNIException Thrown by handler to signal an error.
 */
public void startDocument(XMLLocator locator, String encoding,
                          NamespaceContext namespaceContext, Augmentations augs)
    throws XNIException {

    fNamespaceContext = namespaceContext;

    try {
        // SAX1
        if (fDocumentHandler != null) {
            if (locator != null) {
                fDocumentHandler.setDocumentLocator(new LocatorProxy(locator));
            }
            fDocumentHandler.startDocument();
        }

        // SAX2
        if (fContentHandler != null) {
            if (locator != null) {
                fContentHandler.setDocumentLocator(new LocatorProxy(locator));
            }
            fContentHandler.startDocument();
        }
    }
    catch (SAXException e) {
        throw new XNIException(e);
    }

}
 
Example #27
Source File: XML11Configuration.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * reset all components before parsing and namespace context
 */
protected void resetXML11() throws XNIException {
        // reset every component
        int count = fXML11Components.size();
        for (int i = 0; i < count; i++) {
                XMLComponent c = (XMLComponent) fXML11Components.get(i);
                c.reset(this);
        }

}
 
Example #28
Source File: XIncludeHandler.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void endDTD(Augmentations augmentations) throws XNIException {
    if (fDTDHandler != null) {
        fDTDHandler.endDTD(augmentations);
    }
    fInDTD = false;
}
 
Example #29
Source File: XMLDocumentFilterImpl.java    From JDKSourceCode1.8 with MIT License 4 votes vote down vote up
public void endGeneralEntity(String name, Augmentations augs) throws XNIException {
    next.endGeneralEntity(name, augs);
}
 
Example #30
Source File: XMLDocumentFragmentScannerImpl.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
/** return the next state on the input
 * @return int
 */

public int next() throws IOException, XNIException {
    return fDriver.next();
}