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

The following examples show how to use com.sun.org.apache.xerces.internal.xni.XMLResourceIdentifier. 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: DTDGrammar.java    From hottub 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 {

    XMLEntityDecl  entityDecl = new XMLEntityDecl();
    boolean isPE = name.startsWith("%");
    boolean inExternal = (fReadingExternalDTD || fPEDepth > 0);

    entityDecl.setValues(name,identifier.getPublicId(),identifier.getLiteralSystemId(),
                        identifier.getBaseSystemId(), notation,
                        null, isPE, inExternal);
    int entityIndex = getEntityDeclIndex(name);
    if (entityIndex == -1) {
        entityIndex = createEntityDecl();
        setEntityDecl(entityIndex, entityDecl);
    }

}
 
Example #2
Source File: AbstractDOMParser.java    From openjdk-jdk9 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 (DEBUG_EVENTS) {
        System.out.println ("==>startParameterEntity: "+name);
        if (DEBUG_BASEURI) {
            System.out.println ("   expandedSystemId: "+identifier.getExpandedSystemId ());
            System.out.println ("   baseURI:"+ identifier.getBaseSystemId ());
        }
    }
    if (augs != null && fInternalSubset != null &&
        !fInDTDExternalSubset &&
        Boolean.TRUE.equals(augs.getItem(Constants.ENTITY_SKIPPED))) {
        fInternalSubset.append(name).append(";\n");
    }
    fBaseURIStack.push (identifier.getExpandedSystemId ());
}
 
Example #3
Source File: XIncludeHandler.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Caches an unparsed entity.
 * @param name the name of the unparsed entity
 * @param identifier the location of the unparsed entity
 * @param augmentations any Augmentations that were on the original unparsed entity declaration
 */
protected void addUnparsedEntity(
    String name,
    XMLResourceIdentifier identifier,
    String notation,
    Augmentations augmentations) {
    UnparsedEntity ent = new UnparsedEntity();
    ent.name = name;
    ent.systemId = identifier.getLiteralSystemId();
    ent.publicId = identifier.getPublicId();
    ent.baseURI = identifier.getBaseSystemId();
    ent.expandedSystemId = identifier.getExpandedSystemId();
    ent.notation = notation;
    ent.augmentations = augmentations;
    fUnparsedEntities.add(ent);
}
 
Example #4
Source File: DTDGrammar.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * An external 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 identifier    An object containing all location information
 *                      pertinent to this external entity declaration.
 * @param augs Additional information that may include infoset
 *                      augmentations.
 * @throws XNIException Thrown by handler to signal an error.
 */
public void externalEntityDecl(String name,
                               XMLResourceIdentifier identifier,
                               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, identifier.getPublicId(), identifier.getLiteralSystemId(),
                            identifier.getBaseSystemId(),
                            null, null, isPE, inExternal);

        setEntityDecl(entityIndex, entityDecl);
    }
}
 
Example #5
Source File: XMLDTDProcessor.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * A notation declaration
 *
 * @param name     The name of the notation.
 * @param identifier    An object containing all location information
 *                      pertinent to this notation.
 * @param augs Additional information that may include infoset
 *                      augmentations.
 *
 * @throws XNIException Thrown by handler to signal an error.
 */
public void notationDecl(String name, XMLResourceIdentifier identifier,
                         Augmentations augs) throws XNIException {

    // VC: Unique Notation Name
    if (fValidation) {
        DTDGrammar grammar = (fDTDGrammar != null ? fDTDGrammar : fGrammarBucket.getActiveGrammar());
        if (grammar.getNotationDeclIndex(name) != -1) {
            fErrorReporter.reportError(XMLMessageFormatter.XML_DOMAIN,
                                       "UniqueNotationName",
                                       new Object[]{name},
                                       XMLErrorReporter.SEVERITY_ERROR);
        }
    }

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

}
 
Example #6
Source File: XMLDocumentScannerImpl.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * This method notifies of the start of an entity. The DTD has the
 * pseudo-name of "[dtd]" parameter entity names start with '%'; and
 * general entities are just specified by their name.
 *
 * @param name     The name of the 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 entities or a document entity that is
 *                 parsed from a java.io.Reader).
 *
 * @throws XNIException Thrown by handler to signal an error.
 */
public void startEntity(String name,
        XMLResourceIdentifier identifier,
        String encoding, Augmentations augs) throws XNIException {

    super.startEntity(name, identifier, encoding,augs);

    //register current document scanner as a listener for XMLEntityScanner
    fEntityScanner.registerListener(this);

    // prepare to look for a TextDecl if external general entity
    if (!name.equals("[xml]") && fEntityScanner.isExternal()) {
        // Don't do this if we're skipping the entity!
        if (augs == null || !((Boolean) augs.getItem(Constants.ENTITY_SKIPPED)).booleanValue()) {
            setScannerState(SCANNER_STATE_TEXT_DECL);
        }
    }

    // call handler
    /** comment this part.. LOCATOR problem.. */
    if (fDocumentHandler != null && name.equals("[xml]")) {
        fDocumentHandler.startDocument(fEntityScanner, encoding, fNamespaceContext, null);
    }

}
 
Example #7
Source File: AbstractSAXParser.java    From jdk1.8-source-analysis with Apache License 2.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 {
    try {
        // SAX2 extension
        if (fDTDHandler != null) {
            String publicId = identifier.getPublicId();
            String systemId = fResolveDTDURIs ?
                identifier.getExpandedSystemId() : identifier.getLiteralSystemId();
            fDTDHandler.unparsedEntityDecl(name, publicId, systemId, notation);
        }
    }
    catch (SAXException e) {
        throw new XNIException(e);
    }

}
 
Example #8
Source File: Entity.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
/** Constructs a scanned entity. */
public ScannedEntity(String name,
        XMLResourceIdentifier entityLocation,
        InputStream stream, Reader reader,
        String encoding, boolean literal, boolean mayReadChunks, boolean isExternal) {
    this.name = name ;
    this.entityLocation = entityLocation;
    this.stream = stream;
    this.reader = reader;
    this.encoding = encoding;
    this.literal = literal;
    this.mayReadChunks = mayReadChunks;
    this.isExternal = isExternal;
    final int size = isExternal ? fBufferSize : DEFAULT_INTERNAL_BUFFER_SIZE;
    BufferAllocator ba = ThreadLocalBufferAllocator.getBufferAllocator();
    ch = ba.getCharBuffer(size);
    if (ch == null) {
        this.ch = new char[size];
    }
}
 
Example #9
Source File: XMLDocumentScannerImpl.java    From Bytecoder with Apache License 2.0 6 votes vote down vote up
/**
 * This method notifies of the start of an entity. The DTD has the
 * pseudo-name of "[dtd]" parameter entity names start with '%'; and
 * general entities are just specified by their name.
 *
 * @param name     The name of the 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 entities or a document entity that is
 *                 parsed from a java.io.Reader).
 *
 * @throws XNIException Thrown by handler to signal an error.
 */
public void startEntity(String name,
        XMLResourceIdentifier identifier,
        String encoding, Augmentations augs) throws XNIException {

    super.startEntity(name, identifier, encoding,augs);

    //register current document scanner as a listener for XMLEntityScanner
    fEntityScanner.registerListener(this);

    // prepare to look for a TextDecl if external general entity
    if (!name.equals("[xml]") && fEntityScanner.isExternal()) {
        // Don't do this if we're skipping the entity!
        if (augs == null || !((Boolean) augs.getItem(Constants.ENTITY_SKIPPED)).booleanValue()) {
            setScannerState(SCANNER_STATE_TEXT_DECL);
        }
    }

    // call handler
    /** comment this part.. LOCATOR problem.. */
    if (fDocumentHandler != null && name.equals("[xml]")) {
        fDocumentHandler.startDocument(fEntityScanner, encoding, fNamespaceContext, null);
    }

}
 
Example #10
Source File: AbstractSAXParser.java    From Bytecoder with Apache License 2.0 6 votes vote down vote up
/**
 * This method notifies of the start of an entity. The DTD has the
 * pseudo-name of "[dtd]" parameter entity names start with '%'; and
 * general entity names are just the entity name.
 * <p>
 * <strong>Note:</strong> Since the document is an entity, the handler
 * will be notified of the start of the document entity by calling the
 * startEntity method with the entity name "[xml]" <em>before</em> calling
 * the startDocument method. When exposing entity boundaries through the
 * SAX API, the document entity is never reported, however.
 * <p>
 * <strong>Note:</strong> This method is not called for entity references
 * appearing as part of attribute values.
 *
 * @param name     The name of the 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 startGeneralEntity(String name, XMLResourceIdentifier identifier,
                               String encoding, Augmentations augs)
    throws XNIException {

    try {
        // Only report startEntity if this entity was actually read.
        if (augs != null && Boolean.TRUE.equals(augs.getItem(Constants.ENTITY_SKIPPED))) {
            // report skipped entity to content handler
            if (fContentHandler != null) {
                fContentHandler.skippedEntity(name);
            }
        }
        else {
            // SAX2 extension
            if (fLexicalHandler != null) {
                fLexicalHandler.startEntity(name);
            }
        }
    }
    catch (SAXException e) {
        throw new XNIException(e);
    }

}
 
Example #11
Source File: AbstractSAXParser.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * An external 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 identifier    An object containing all location information
 *                      pertinent to this entity.
 * @param augs Additional information that may include infoset
 *                      augmentations.
 *
 * @throws XNIException Thrown by handler to signal an error.
 */
public void externalEntityDecl(String name, XMLResourceIdentifier identifier,
                               Augmentations augs) throws XNIException {
    try {
        // SAX2 extension
        if (fDeclHandler != null) {
            String publicId = identifier.getPublicId();
            String systemId = fResolveDTDURIs ?
                identifier.getExpandedSystemId() : identifier.getLiteralSystemId();
            fDeclHandler.externalEntityDecl(name, publicId, systemId);
        }
    }
    catch (SAXException e) {
        throw new XNIException(e);
    }

}
 
Example #12
Source File: DTDGrammar.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * An external 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 identifier    An object containing all location information
 *                      pertinent to this external entity declaration.
 * @param augs Additional information that may include infoset
 *                      augmentations.
 * @throws XNIException Thrown by handler to signal an error.
 */
public void externalEntityDecl(String name,
                               XMLResourceIdentifier identifier,
                               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, identifier.getPublicId(), identifier.getLiteralSystemId(),
                            identifier.getBaseSystemId(),
                            null, null, isPE, inExternal);

        setEntityDecl(entityIndex, entityDecl);
    }
}
 
Example #13
Source File: DTDGrammar.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/**
 * An external 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 identifier    An object containing all location information
 *                      pertinent to this external entity declaration.
 * @param augs Additional information that may include infoset
 *                      augmentations.
 * @throws XNIException Thrown by handler to signal an error.
 */
public void externalEntityDecl(String name,
                               XMLResourceIdentifier identifier,
                               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, identifier.getPublicId(), identifier.getLiteralSystemId(),
                            identifier.getBaseSystemId(),
                            null, null, isPE, inExternal);

        setEntityDecl(entityIndex, entityDecl);
    }
}
 
Example #14
Source File: XMLDTDProcessor.java    From Bytecoder with Apache License 2.0 6 votes vote down vote up
/**
 * A notation declaration
 *
 * @param name     The name of the notation.
 * @param identifier    An object containing all location information
 *                      pertinent to this notation.
 * @param augs Additional information that may include infoset
 *                      augmentations.
 *
 * @throws XNIException Thrown by handler to signal an error.
 */
public void notationDecl(String name, XMLResourceIdentifier identifier,
                         Augmentations augs) throws XNIException {

    // VC: Unique Notation Name
    if (fValidation) {
        DTDGrammar grammar = (fDTDGrammar != null ? fDTDGrammar : fGrammarBucket.getActiveGrammar());
        if (grammar.getNotationDeclIndex(name) != -1) {
            fErrorReporter.reportError(XMLMessageFormatter.XML_DOMAIN,
                                       "UniqueNotationName",
                                       new Object[]{name},
                                       XMLErrorReporter.SEVERITY_ERROR);
        }
    }

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

}
 
Example #15
Source File: XMLDTDValidator.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
/**
 * This method notifies the start of a general entity.
 * <p>
 * <strong>Note:</strong> This method is not called for entity references
 * appearing as part of attribute values.
 *
 * @param name     The name of the general 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 entities or a document entity that is
 *                 parsed from a java.io.Reader).
 * @param augs     Additional information that may include infoset augmentations
 *
 * @exception XNIException Thrown by handler to signal an error.
 */
public void startGeneralEntity(String name,
                               XMLResourceIdentifier identifier,
                               String encoding,
                               Augmentations augs) throws XNIException {
    if (fPerformValidation && fElementDepth >= 0 && fDTDGrammar != null) {
        fDTDGrammar.getElementDecl(fCurrentElementIndex, fTempElementDecl);
        // fixes E15.1
        if (fTempElementDecl.type == XMLElementDecl.TYPE_EMPTY) {
            fErrorReporter.reportError(XMLMessageFormatter.XML_DOMAIN,
                                       "MSG_CONTENT_INVALID_SPECIFIED",
                                       new Object[]{ fCurrentElement.rawname,
                                                     "EMPTY", "ENTITY"},
                                       XMLErrorReporter.SEVERITY_ERROR);
        }
        if (fGrammarBucket.getStandalone()) {
            XMLDTDLoader.checkStandaloneEntityRef(name, fDTDGrammar, fEntityDecl, fErrorReporter);
        }
    }
    if (fDocumentHandler != null) {
        fDocumentHandler.startGeneralEntity(name, identifier, encoding, augs);
    }
}
 
Example #16
Source File: XMLDTDProcessor.java    From hottub 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 #17
Source File: XMLDTDValidator.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * This method notifies the start of a general entity.
 * <p>
 * <strong>Note:</strong> This method is not called for entity references
 * appearing as part of attribute values.
 *
 * @param name     The name of the general 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 entities or a document entity that is
 *                 parsed from a java.io.Reader).
 * @param augs     Additional information that may include infoset augmentations
 *
 * @exception XNIException Thrown by handler to signal an error.
 */
public void startGeneralEntity(String name,
                               XMLResourceIdentifier identifier,
                               String encoding,
                               Augmentations augs) throws XNIException {
    if (fPerformValidation && fElementDepth >= 0 && fDTDGrammar != null) {
        fDTDGrammar.getElementDecl(fCurrentElementIndex, fTempElementDecl);
        // fixes E15.1
        if (fTempElementDecl.type == XMLElementDecl.TYPE_EMPTY) {
            fErrorReporter.reportError(XMLMessageFormatter.XML_DOMAIN,
                                       "MSG_CONTENT_INVALID_SPECIFIED",
                                       new Object[]{ fCurrentElement.rawname,
                                                     "EMPTY", "ENTITY"},
                                       XMLErrorReporter.SEVERITY_ERROR);
        }
        if (fGrammarBucket.getStandalone()) {
            XMLDTDLoader.checkStandaloneEntityRef(name, fDTDGrammar, fEntityDecl, fErrorReporter);
        }
    }
    if (fDocumentHandler != null) {
        fDocumentHandler.startGeneralEntity(name, identifier, encoding, augs);
    }
}
 
Example #18
Source File: DTDGrammar.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * An external 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 identifier    An object containing all location information
 *                      pertinent to this external entity declaration.
 * @param augs Additional information that may include infoset
 *                      augmentations.
 * @throws XNIException Thrown by handler to signal an error.
 */
public void externalEntityDecl(String name,
                               XMLResourceIdentifier identifier,
                               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, identifier.getPublicId(), identifier.getLiteralSystemId(),
                            identifier.getBaseSystemId(),
                            null, null, isPE, inExternal);

        setEntityDecl(entityIndex, entityDecl);
    }
}
 
Example #19
Source File: UnparsedEntityHandler.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
public void externalEntityDecl(String name,
        XMLResourceIdentifier identifier, Augmentations augmentations)
        throws XNIException {
    if (fDTDHandler != null) {
        fDTDHandler.externalEntityDecl(name, identifier, augmentations);
    }
}
 
Example #20
Source File: XIncludeHandler.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * The purpose of this method is to check if a Notation conflicts with a previously
 * declared notation in the current pipeline stack.  If there is no conflict, the
 * Notation is sent by the root pipeline.
 *
 * @param not the Notation to check for conflicts
 */
protected void checkAndSendNotation(Notation not) {
    if (isRootDocument()) {
        int index = fNotations.indexOf(not);
        if (index == -1) {
            // There is no notation with the same name that we have sent.
            XMLResourceIdentifier id =
                new XMLResourceIdentifierImpl(
                    not.publicId,
                    not.systemId,
                    not.baseURI,
                    not.expandedSystemId);
            addNotation(not.name, id, not.augmentations);
            if (fSendUEAndNotationEvents && fDTDHandler != null) {
                fDTDHandler.notationDecl(not.name, id, not.augmentations);
            }
        }
        else {
            Notation localNotation = (Notation)fNotations.get(index);
            if (!not.isDuplicate(localNotation)) {
                reportFatalError(
                    "NonDuplicateNotation",
                    new Object[] { not.name });
            }
        }
    }
    else {
        fParentXIncludeHandler.checkAndSendNotation(not);
    }
}
 
Example #21
Source File: DOMEntityResolverWrapper.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/** Determines the type of resource being resolved **/
private String getType(XMLResourceIdentifier resourceIdentifier) {
    if (resourceIdentifier instanceof XMLGrammarDescription) {
        XMLGrammarDescription desc = (XMLGrammarDescription) resourceIdentifier;
        if (XMLGrammarDescription.XML_SCHEMA.equals(desc.getGrammarType())) {
            return XSD_TYPE;
        }
    }
    return XML_TYPE;
}
 
Example #22
Source File: Entity.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/** Constructs an internal entity. */
public ExternalEntity(String name, XMLResourceIdentifier entityLocation,
        String notation, boolean inExternalSubset) {
    super(name,inExternalSubset);
    this.entityLocation = entityLocation;
    this.notation = notation;
}
 
Example #23
Source File: XIncludeHandler.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
@Override
public void externalEntityDecl(
    String name,
    XMLResourceIdentifier identifier,
    Augmentations augmentations)
    throws XNIException {
    if (fDTDHandler != null) {
        fDTDHandler.externalEntityDecl(name, identifier, augmentations);
    }
}
 
Example #24
Source File: XIncludeHandler.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
@Override
public void startParameterEntity(
    String name,
    XMLResourceIdentifier identifier,
    String encoding,
    Augmentations augmentations)
    throws XNIException {
    if (fDTDHandler != null) {
        fDTDHandler.startParameterEntity(
            name,
            identifier,
            encoding,
            augmentations);
    }
}
 
Example #25
Source File: AbstractDOMParser.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * The start of the DTD external subset.
 *
 * @param augs Additional information that may include infoset
 *                      augmentations.
 *
 * @throws XNIException Thrown by handler to signal an error.
 */
public void startExternalSubset (XMLResourceIdentifier identifier,
Augmentations augs) throws XNIException {
    if (DEBUG_EVENTS) {
        System.out.println ("==>startExternalSubset");
        if (DEBUG_BASEURI) {
            System.out.println ("   expandedSystemId: "+identifier.getExpandedSystemId ());
            System.out.println ("   baseURI:"+ identifier.getBaseSystemId ());
        }
    }
    fBaseURIStack.push (identifier.getBaseSystemId ());
    fInDTDExternalSubset = true;
}
 
Example #26
Source File: XMLDTDScannerImpl.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * This method notifies of the start of an entity. The DTD has the
 * pseudo-name of "[dtd]" parameter entity names start with '%'; and
 * general entities are just specified by their name.
 *
 * @param name     The name of the 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 entities or a document entity that is
 *                 parsed from a java.io.Reader).
 * @param augs     Additional information that may include infoset augmentations
 *
 * @throws XNIException Thrown by handler to signal an error.
 */
public void startEntity(String name,
                        XMLResourceIdentifier identifier,
                        String encoding, Augmentations augs) throws XNIException {

    super.startEntity(name, identifier, encoding, augs);

    boolean dtdEntity = name.equals("[dtd]");
    if (dtdEntity) {
        // call handler
        if (fDTDHandler != null && !fStartDTDCalled ) {
            fDTDHandler.startDTD(fEntityScanner, null);
        }
        if (fDTDHandler != null) {
            fDTDHandler.startExternalSubset(identifier,null);
        }
        fEntityManager.startExternalSubset();
        fEntityStore.startExternalSubset();
        fExtEntityDepth++;
    }
    else if (name.charAt(0) == '%') {
        pushPEStack(fMarkUpDepth, fReportEntity);
        if (fEntityScanner.isExternal()) {
            fExtEntityDepth++;
        }
    }

    // call handler
    if (fDTDHandler != null && !dtdEntity && fReportEntity) {
        fDTDHandler.startParameterEntity(name, identifier, encoding, null);
    }

}
 
Example #27
Source File: XIncludeHandler.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void notationDecl(
    String name,
    XMLResourceIdentifier identifier,
    Augmentations augmentations)
    throws XNIException {
    this.addNotation(name, identifier, augmentations);
    if (fDTDHandler != null) {
        fDTDHandler.notationDecl(name, identifier, augmentations);
    }
}
 
Example #28
Source File: XIncludeHandler.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
@Override
public void startExternalSubset(
    XMLResourceIdentifier identifier,
    Augmentations augmentations)
    throws XNIException {
    if (fDTDHandler != null) {
        fDTDHandler.startExternalSubset(identifier, augmentations);
    }
}
 
Example #29
Source File: XIncludeHandler.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
/**
 * The purpose of this method is to check if a Notation conflicts with a previously
 * declared notation in the current pipeline stack.  If there is no conflict, the
 * Notation is sent by the root pipeline.
 *
 * @param not the Notation to check for conflicts
 */
protected void checkAndSendNotation(Notation not) {
    if (isRootDocument()) {
        int index = fNotations.indexOf(not);
        if (index == -1) {
            // There is no notation with the same name that we have sent.
            XMLResourceIdentifier id =
                new XMLResourceIdentifierImpl(
                    not.publicId,
                    not.systemId,
                    not.baseURI,
                    not.expandedSystemId);
            addNotation(not.name, id, not.augmentations);
            if (fSendUEAndNotationEvents && fDTDHandler != null) {
                fDTDHandler.notationDecl(not.name, id, not.augmentations);
            }
        }
        else {
            Notation localNotation = (Notation)fNotations.get(index);
            if (!not.isDuplicate(localNotation)) {
                reportFatalError(
                    "NonDuplicateNotation",
                    new Object[] { not.name });
            }
        }
    }
    else {
        fParentXIncludeHandler.checkAndSendNotation(not);
    }
}
 
Example #30
Source File: XMLCatalogResolver.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * <p>Resolves an identifier using the catalog. This method interprets that
 * the namespace of the identifier corresponds to uri entries in the catalog.
 * Where both a namespace and an external identifier exist, the namespace
 * takes precedence.</p>
 *
 * @param resourceIdentifier the identifier to resolve
 *
 * @throws XNIException thrown on general error
 * @throws IOException thrown if some i/o error occurs
 */
public String resolveIdentifier(XMLResourceIdentifier resourceIdentifier)
    throws IOException, XNIException {

    String resolvedId = null;

    // The namespace is useful for resolving namespace aware
    // grammars such as XML schema. Let it take precedence over
    // the external identifier if one exists.
    String namespace = resourceIdentifier.getNamespace();
    if (namespace != null) {
        resolvedId = resolveURI(namespace);
    }

    // Resolve against an external identifier if one exists. This
    // is useful for resolving DTD external subsets and other
    // external entities. For XML schemas if there was no namespace
    // mapping we might be able to resolve a system identifier
    // specified as a location hint.
    if (resolvedId == null) {
        String publicId = resourceIdentifier.getPublicId();
        String systemId = getUseLiteralSystemId()
            ? resourceIdentifier.getLiteralSystemId()
            : resourceIdentifier.getExpandedSystemId();
        if (publicId != null && systemId != null) {
            resolvedId = resolvePublic(publicId, systemId);
        }
        else if (systemId != null) {
            resolvedId = resolveSystem(systemId);
        }
    }
    return resolvedId;
}