com.sun.org.apache.xerces.internal.impl.Constants Java Examples

The following examples show how to use com.sun.org.apache.xerces.internal.impl.Constants. 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: DOMParserImpl.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Constructs a DOM Builder using the standard parser configuration.
 */
public DOMParserImpl (XMLParserConfiguration config, String schemaType) {
    this (config);
    if (schemaType != null) {
        if (schemaType.equals (Constants.NS_DTD)) {
            //Schema validation is false by default and hence there is no
            //need to set it to false here.  Also, schema validation is
            //not a recognized feature for DTDConfiguration's and so
            //setting this feature here would result in a Configuration
            //Exception.
            fConfiguration.setProperty (
            Constants.JAXP_PROPERTY_PREFIX + Constants.SCHEMA_LANGUAGE,
            Constants.NS_DTD);
            fSchemaType = Constants.NS_DTD;
        }
        else if (schemaType.equals (Constants.NS_XMLSCHEMA)) {
            // XML Schem validation
            fConfiguration.setProperty (
            Constants.JAXP_PROPERTY_PREFIX + Constants.SCHEMA_LANGUAGE,
            Constants.NS_XMLSCHEMA);
        }
    }

}
 
Example #2
Source File: CMNodeFactory.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Sets the value of a property. This method is called by the component
 * manager any time after reset when a property changes value.
 * <p>
 * <strong>Note:</strong> Components should silently ignore properties
 * that do not affect the operation of the component.
 *
 * @param propertyId The property identifier.
 * @param value      The value of the property.
 *
 * @throws SAXNotRecognizedException The component should not throw
 *                                   this exception.
 * @throws SAXNotSupportedException The component should not throw
 *                                  this exception.
 */
public void setProperty(String propertyId, Object value)
    throws XMLConfigurationException {

    // Xerces properties
    if (propertyId.startsWith(Constants.XERCES_PROPERTY_PREFIX)) {
            final int suffixLength = propertyId.length() - Constants.XERCES_PROPERTY_PREFIX.length();

        if (suffixLength == Constants.SECURITY_MANAGER_PROPERTY.length() &&
            propertyId.endsWith(Constants.SECURITY_MANAGER_PROPERTY)) {
            fSecurityManager = (XMLSecurityManager)value;
            maxNodeLimit = (fSecurityManager != null) ?
                    fSecurityManager.getLimit(XMLSecurityManager.Limit.MAX_OCCUR_NODE_LIMIT) * MULTIPLICITY : 0 ;
            return;
        }
        if (suffixLength == Constants.ERROR_REPORTER_PROPERTY.length() &&
            propertyId.endsWith(Constants.ERROR_REPORTER_PROPERTY)) {
            fErrorReporter = (XMLErrorReporter)value;
            return;
        }
    }

}
 
Example #3
Source File: CMNodeFactory.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Sets the value of a property. This method is called by the component
 * manager any time after reset when a property changes value.
 * <p>
 * <strong>Note:</strong> Components should silently ignore properties
 * that do not affect the operation of the component.
 *
 * @param propertyId The property identifier.
 * @param value      The value of the property.
 *
 * @throws SAXNotRecognizedException The component should not throw
 *                                   this exception.
 * @throws SAXNotSupportedException The component should not throw
 *                                  this exception.
 */
public void setProperty(String propertyId, Object value)
    throws XMLConfigurationException {

    // Xerces properties
    if (propertyId.startsWith(Constants.XERCES_PROPERTY_PREFIX)) {
            final int suffixLength = propertyId.length() - Constants.XERCES_PROPERTY_PREFIX.length();

        if (suffixLength == Constants.SECURITY_MANAGER_PROPERTY.length() &&
            propertyId.endsWith(Constants.SECURITY_MANAGER_PROPERTY)) {
            fSecurityManager = (XMLSecurityManager)value;
            maxNodeLimit = (fSecurityManager != null) ?
                    fSecurityManager.getLimit(XMLSecurityManager.Limit.MAX_OCCUR_NODE_LIMIT) * MULTIPLICITY : 0 ;
            return;
        }
        if (suffixLength == Constants.ERROR_REPORTER_PROPERTY.length() &&
            propertyId.endsWith(Constants.ERROR_REPORTER_PROPERTY)) {
            fErrorReporter = (XMLErrorReporter)value;
            return;
        }
    }

}
 
Example #4
Source File: AbstractSAXParser.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
/**
 * This method notifies of the start of parameter 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 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 {

    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 && fLexicalHandlerParameterEntities) {
                fLexicalHandler.startEntity(name);
            }
        }
    }
    catch (SAXException e) {
        throw new XNIException(e);
    }

}
 
Example #5
Source File: DOMResultBuilder.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
public void endElement(QName element, Augmentations augs)
        throws XNIException {
    // 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)fCurrentNode).setPSVI(elementPSVI);
            }
            XSTypeDefinition type = elementPSVI.getMemberTypeDefinition();
            if (type == null) {
                type = elementPSVI.getTypeDefinition();
            }
            ((ElementNSImpl)fCurrentNode).setType(type);
        }
    }

    // adjust current node reference
    if (fCurrentNode == fFragmentRoot) {
        fCurrentNode = null;
        fFragmentRoot = null;
        return;
    }
    fCurrentNode = fCurrentNode.getParentNode();
}
 
Example #6
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 #7
Source File: XMLSchemaLoader.java    From Bytecoder with Apache License 2.0 6 votes vote down vote up
/**
 * This method is called either from XMLGrammarLoader.loadGrammar or from XMLSchemaValidator.
 * Note: in either case, the EntityManager (or EntityResolvers) are not going to be invoked
 * to resolve the location of the schema in XSDDescription
 * @param desc
 * @param source
 * @param locationPairs
 * @return An XML Schema grammar
 * @throws IOException
 * @throws XNIException
 */
SchemaGrammar loadSchema(XSDDescription desc, XMLInputSource source,
        Map<String, LocationArray> locationPairs) throws IOException, XNIException {

    // this should only be done once per invocation of this object;
    // unless application alters JAXPSource in the mean time.
    if(!fJAXPProcessed) {
        processJAXPSchemaSource(locationPairs);
    }

    if (desc.isExternal() && !source.isCreatedByResolver()) {
        String accessError = SecuritySupport.checkAccess(desc.getExpandedSystemId(), faccessExternalSchema, Constants.ACCESS_EXTERNAL_ALL);
        if (accessError != null) {
            throw new XNIException(fErrorReporter.reportError(XSMessageFormatter.SCHEMA_DOMAIN,
                    "schema_reference.access",
                    new Object[] { SecuritySupport.sanitizePath(desc.getExpandedSystemId()), accessError }, XMLErrorReporter.SEVERITY_ERROR));
        }
    }
    SchemaGrammar grammar = fSchemaHandler.parseSchema(source, desc, locationPairs);

    return grammar;
}
 
Example #8
Source File: DOMResultAugmentor.java    From openjdk-jdk9 with GNU General Public License v2.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 #9
Source File: XSSimpleTypeDecl.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
private short getPrimitiveDV(short validationDV){

        if (validationDV == DV_ID || validationDV == DV_IDREF || validationDV == DV_ENTITY){
            return DV_STRING;
        }
        else if (validationDV == DV_INTEGER) {
            return DV_DECIMAL;
        }
        else if (Constants.SCHEMA_1_1_SUPPORT && (validationDV == DV_YEARMONTHDURATION || validationDV == DV_DAYTIMEDURATION)) {
            return DV_DURATION;
        }
        else {
            return validationDV;
        }

    }
 
Example #10
Source File: ValidatorHandlerImpl.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
AttributePSVI getAttributePSVI(int index) {
    if (fAttributes != null) {
        Augmentations augs = fAttributes.getAugmentations(index);
        if (augs != null) {
            return (AttributePSVI) augs.getItem(Constants.ATTRIBUTE_PSVI);
        }
    }
    return null;
}
 
Example #11
Source File: XMLSchemaValidatorComponentManager.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Set the state of a feature.
 *
 * @param featureId The unique identifier (URI) of the feature.
 * @param state The requested state of the feature (true or false).
 *
 * @exception XMLConfigurationException If the requested feature is not known.
 */
public void setFeature(String featureId, boolean value) throws XMLConfigurationException {
    if (PARSER_SETTINGS.equals(featureId)) {
        throw new XMLConfigurationException(Status.NOT_SUPPORTED, featureId);
    }
    else if (value == false && (VALIDATION.equals(featureId) || SCHEMA_VALIDATION.equals(featureId))) {
        throw new XMLConfigurationException(Status.NOT_SUPPORTED, featureId);
    }
    else if (USE_GRAMMAR_POOL_ONLY.equals(featureId) && value != fUseGrammarPoolOnly) {
        throw new XMLConfigurationException(Status.NOT_SUPPORTED, featureId);
    }
    if (XMLConstants.FEATURE_SECURE_PROCESSING.equals(featureId)) {
        if (_isSecureMode && !value) {
            throw new XMLConfigurationException(Status.NOT_ALLOWED, XMLConstants.FEATURE_SECURE_PROCESSING);
        }

        fInitSecurityManager.setSecureProcessing(value);
        setProperty(SECURITY_MANAGER, fInitSecurityManager);

        if (value && Constants.IS_JDK8_OR_ABOVE) {
            fSecurityPropertyMgr.setValue(XMLSecurityPropertyManager.Property.ACCESS_EXTERNAL_DTD,
                    XMLSecurityPropertyManager.State.FSP, Constants.EXTERNAL_ACCESS_DEFAULT_FSP);
            fSecurityPropertyMgr.setValue(XMLSecurityPropertyManager.Property.ACCESS_EXTERNAL_SCHEMA,
                    XMLSecurityPropertyManager.State.FSP, Constants.EXTERNAL_ACCESS_DEFAULT_FSP);
            setProperty(XML_SECURITY_PROPERTY_MANAGER, fSecurityPropertyMgr);
        }

        return;
    }
    fConfigUpdated = true;
    fEntityManager.setFeature(featureId, value);
    fErrorReporter.setFeature(featureId, value);
    fSchemaValidator.setFeature(featureId, value);
    if (!fInitFeatures.containsKey(featureId)) {
        boolean current = super.getFeature(featureId);
        fInitFeatures.put(featureId, current ? Boolean.TRUE : Boolean.FALSE);
    }
    super.setFeature(featureId, value);
}
 
Example #12
Source File: XMLSchemaFactory.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
private void propagateFeatures(AbstractXMLSchema schema) {
    schema.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, fSecurityManager != null);
    schema.setFeature(Constants.ORACLE_FEATURE_SERVICE_MECHANISM, fUseServicesMechanism);
    String[] features = fXMLSchemaLoader.getRecognizedFeatures();
    for (int i = 0; i < features.length; ++i) {
        boolean state = fXMLSchemaLoader.getFeature(features[i]);
        schema.setFeature(features[i], state);
    }
}
 
Example #13
Source File: StreamValidatorHelper.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
private XMLParserConfiguration initialize() {
    XML11Configuration config = new XML11Configuration();
    if (fComponentManager.getFeature(XMLConstants.FEATURE_SECURE_PROCESSING)) {
        config.setProperty(SECURITY_MANAGER, new XMLSecurityManager());
    }
    config.setProperty(ENTITY_RESOLVER, fComponentManager.getProperty(ENTITY_RESOLVER));
    config.setProperty(ERROR_HANDLER, fComponentManager.getProperty(ERROR_HANDLER));
    XMLErrorReporter errorReporter = (XMLErrorReporter) fComponentManager.getProperty(ERROR_REPORTER);
    config.setProperty(ERROR_REPORTER, errorReporter);
    // add message formatters
    if (errorReporter.getMessageFormatter(XMLMessageFormatter.XML_DOMAIN) == null) {
        XMLMessageFormatter xmft = new XMLMessageFormatter();
        errorReporter.putMessageFormatter(XMLMessageFormatter.XML_DOMAIN, xmft);
        errorReporter.putMessageFormatter(XMLMessageFormatter.XMLNS_DOMAIN, xmft);
    }
    config.setProperty(SYMBOL_TABLE, fComponentManager.getProperty(SYMBOL_TABLE));
    config.setProperty(VALIDATION_MANAGER, fComponentManager.getProperty(VALIDATION_MANAGER));
    config.setDocumentHandler(fSchemaValidator);
    config.setDTDHandler(null);
    config.setDTDContentModelHandler(null);
    config.setProperty(Constants.XML_SECURITY_PROPERTY_MANAGER,
            fComponentManager.getProperty(Constants.XML_SECURITY_PROPERTY_MANAGER));
    config.setProperty(Constants.SECURITY_MANAGER,
            fComponentManager.getProperty(Constants.SECURITY_MANAGER));
    fConfiguration = new SoftReference(config);
    return config;
}
 
Example #14
Source File: ShortHandPointer.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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;
}
 
Example #15
Source File: AbstractSAXParser.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public boolean isDeclared(int index) {
    if (index < 0 || index >= fAttributes.getLength()) {
        throw new ArrayIndexOutOfBoundsException(index);
    }
    return Boolean.TRUE.equals(
        fAttributes.getAugmentations(index).getItem(
        Constants.ATTRIBUTE_DECLARED));
}
 
Example #16
Source File: XMLSchemaLoader.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public Object getParameter(String name) throws DOMException {

        if (name.equals(Constants.DOM_ERROR_HANDLER)){
            return (fErrorHandler != null) ? fErrorHandler.getErrorHandler() : null;
        }
        else if (name.equals(Constants.DOM_RESOURCE_RESOLVER)) {
            return (fResourceResolver != null) ? fResourceResolver.getEntityResolver() : null;
        }

        try {
            boolean feature = getFeature(name);
            return (feature) ? Boolean.TRUE : Boolean.FALSE;
        } catch (Exception e) {
            Object property;
            try {
                property = getProperty(name);
                return property;
            } catch (Exception ex) {
                String msg =
                    DOMMessageFormatter.formatMessage(
                            DOMMessageFormatter.DOM_DOMAIN,
                            "FEATURE_NOT_SUPPORTED",
                            new Object[] { name });
                throw new DOMException(DOMException.NOT_SUPPORTED_ERR, msg);
            }
        }
    }
 
Example #17
Source File: BasicParserConfiguration.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Check a property. If the property is known and supported, this method
 * simply returns. Otherwise, the appropriate exception is thrown.
 *
 * @param propertyId The unique identifier (URI) of the property
 *                   being set.
 * @exception com.sun.org.apache.xerces.internal.xni.parser.XMLConfigurationException If the
 *            requested feature is not known or supported.
 */
protected PropertyState checkProperty(String propertyId)
    throws XMLConfigurationException {

    // special cases
    if (propertyId.startsWith(Constants.SAX_PROPERTY_PREFIX)) {
        final int suffixLength = propertyId.length() - Constants.SAX_PROPERTY_PREFIX.length();

        //
        // http://xml.org/sax/properties/xml-string
        // Value type: String
        // Access: read-only
        //   Get the literal string of characters associated with the
        //   current event.  If the parser recognises and supports this
        //   property but is not currently parsing text, it should return
        //   null (this is a good way to check for availability before the
        //   parse begins).
        //
        if (suffixLength == Constants.XML_STRING_PROPERTY.length() &&
            propertyId.endsWith(Constants.XML_STRING_PROPERTY)) {
            // REVISIT - we should probably ask xml-dev for a precise
            // definition of what this is actually supposed to return, and
            // in exactly which circumstances.
            return PropertyState.NOT_SUPPORTED;
        }
    }

    // check property
    return super.checkProperty(propertyId);

}
 
Example #18
Source File: XMLInputFactoryImpl.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/** Allows the user to set specific feature/property on the underlying implementation. The underlying implementation
 * is not required to support every setting of every property in the specification and may use IllegalArgumentException
 * to signal that an unsupported property may not be set with the specified value.
 * @param name The name of the property (may not be null)
 * @param value The value of the property
 * @throws java.lang.IllegalArgumentException if the property is not supported
 */
public void setProperty(java.lang.String name, Object value) throws java.lang.IllegalArgumentException {

    if(name == null || value == null || !fPropertyManager.containsProperty(name) ){
        throw new IllegalArgumentException("Property "+name+" is not supported");
    }
    if(name == Constants.REUSE_INSTANCE || name.equals(Constants.REUSE_INSTANCE)){
        fReuseInstance = ((Boolean)value).booleanValue();
        if(DEBUG)System.out.println("fReuseInstance is set to " + fReuseInstance);
    }else{//for any other property set the flag
        //REVISIT: Even in this case instance can be reused, by passing PropertyManager
        fPropertyChanged = true;
    }
    fPropertyManager.setProperty(name,value);
}
 
Example #19
Source File: BasicParserConfiguration.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Check a property. If the property is known and supported, this method
 * simply returns. Otherwise, the appropriate exception is thrown.
 *
 * @param propertyId The unique identifier (URI) of the property
 *                   being set.
 * @exception com.sun.org.apache.xerces.internal.xni.parser.XMLConfigurationException If the
 *            requested feature is not known or supported.
 */
protected PropertyState checkProperty(String propertyId)
    throws XMLConfigurationException {

    // special cases
    if (propertyId.startsWith(Constants.SAX_PROPERTY_PREFIX)) {
        final int suffixLength = propertyId.length() - Constants.SAX_PROPERTY_PREFIX.length();

        //
        // http://xml.org/sax/properties/xml-string
        // Value type: String
        // Access: read-only
        //   Get the literal string of characters associated with the
        //   current event.  If the parser recognises and supports this
        //   property but is not currently parsing text, it should return
        //   null (this is a good way to check for availability before the
        //   parse begins).
        //
        if (suffixLength == Constants.XML_STRING_PROPERTY.length() &&
            propertyId.endsWith(Constants.XML_STRING_PROPERTY)) {
            // REVISIT - we should probably ask xml-dev for a precise
            // definition of what this is actually supposed to return, and
            // in exactly which circumstances.
            return PropertyState.NOT_SUPPORTED;
        }
    }

    // check property
    return super.checkProperty(propertyId);

}
 
Example #20
Source File: DOMParserImpl.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Constructs a DOM Builder using the specified symbol table and
 * grammar pool.
 */
public DOMParserImpl (SymbolTable symbolTable, XMLGrammarPool grammarPool) {
    this (new XIncludeAwareParserConfiguration());
    fConfiguration.setProperty (
    Constants.XERCES_PROPERTY_PREFIX + Constants.SYMBOL_TABLE_PROPERTY,
    symbolTable);
    fConfiguration.setProperty (
    Constants.XERCES_PROPERTY_PREFIX
    + Constants.XMLGRAMMAR_POOL_PROPERTY,
    grammarPool);
}
 
Example #21
Source File: XOMParserTest.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
JDK15XML1_0Parser() throws org.xml.sax.SAXException {

            super(new DTDConfiguration());
            // workaround for Java 1.5 beta 2 bugs
            com.sun.org.apache.xerces.internal.util.SecurityManager manager =
                    new com.sun.org.apache.xerces.internal.util.SecurityManager();
            setProperty(Constants.XERCES_PROPERTY_PREFIX + Constants.SECURITY_MANAGER_PROPERTY, manager);

        }
 
Example #22
Source File: DOMNormalizer.java    From openjdk-8 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 #23
Source File: XMLSecurityPropertyManager.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Read from system properties, or those in jaxp.properties
 */
private void readSystemProperties() {
    getSystemProperty(Property.ACCESS_EXTERNAL_DTD,
            Constants.SP_ACCESS_EXTERNAL_DTD);
    getSystemProperty(Property.ACCESS_EXTERNAL_SCHEMA,
            Constants.SP_ACCESS_EXTERNAL_SCHEMA);
}
 
Example #24
Source File: XMLDocumentParser.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Constructs a document parser using the specified symbol table and
 * grammar pool.
 */
public XMLDocumentParser(SymbolTable symbolTable,
                         XMLGrammarPool grammarPool) {
    super(new XIncludeAwareParserConfiguration());
    fConfiguration.setProperty(Constants.XERCES_PROPERTY_PREFIX+Constants.SYMBOL_TABLE_PROPERTY, symbolTable);
    fConfiguration.setProperty(Constants.XERCES_PROPERTY_PREFIX+Constants.XMLGRAMMAR_POOL_PROPERTY, grammarPool);
}
 
Example #25
Source File: AttributesProxy.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public boolean isDeclared(String qName) {
    int index = getIndex(qName);
    if (index == -1) {
        throw new IllegalArgumentException(qName);
    }
    return Boolean.TRUE.equals(
        fAttributes.getAugmentations(index).getItem(
        Constants.ATTRIBUTE_DECLARED));
}
 
Example #26
Source File: DTDGrammarUtil.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public void reset(XMLComponentManager componentManager)
throws XMLConfigurationException {

    fDTDGrammar = null;
    fInElementContent = false;
    fCurrentElementIndex = -1;
    fCurrentContentSpecType = -1;
    fNamespaces = componentManager.getFeature(NAMESPACES, true);
    fSymbolTable = (SymbolTable) componentManager.getProperty(
            Constants.XERCES_PROPERTY_PREFIX + Constants.SYMBOL_TABLE_PROPERTY);
    fElementDepth = -1;
}
 
Example #27
Source File: ValidatorHandlerImpl.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
AttributePSVI getAttributePSVI(int index) {
    if (fAttributes != null) {
        Augmentations augs = fAttributes.getAugmentations(index);
        if (augs != null) {
            return (AttributePSVI) augs.getItem(Constants.ATTRIBUTE_PSVI);
        }
    }
    return null;
}
 
Example #28
Source File: XMLSchemaLoader.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
public Object getParameter(String name) throws DOMException {

        if (name.equals(Constants.DOM_ERROR_HANDLER)){
            return (fErrorHandler != null) ? fErrorHandler.getErrorHandler() : null;
        }
        else if (name.equals(Constants.DOM_RESOURCE_RESOLVER)) {
            return (fResourceResolver != null) ? fResourceResolver.getEntityResolver() : null;
        }

        try {
            boolean feature = getFeature(name);
            return (feature) ? Boolean.TRUE : Boolean.FALSE;
        } catch (Exception e) {
            Object property;
            try {
                property = getProperty(name);
                return property;
            } catch (Exception ex) {
                String msg =
                    DOMMessageFormatter.formatMessage(
                            DOMMessageFormatter.DOM_DOMAIN,
                            "FEATURE_NOT_SUPPORTED",
                            new Object[] { name });
                throw new DOMException(DOMException.NOT_SUPPORTED_ERR, msg);
            }
        }
    }
 
Example #29
Source File: XMLGrammarCachingConfiguration.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
SchemaGrammar parseXMLSchema(XMLInputSource is)
            throws IOException {
    XMLEntityResolver resolver = getEntityResolver();
    if(resolver != null) {
        fSchemaLoader.setEntityResolver(resolver);
    }
    if (fErrorReporter.getMessageFormatter(XSMessageFormatter.SCHEMA_DOMAIN) == null) {
        fErrorReporter.putMessageFormatter(XSMessageFormatter.SCHEMA_DOMAIN, new XSMessageFormatter());
    }
    fSchemaLoader.setProperty(ERROR_REPORTER, fErrorReporter);

    String propPrefix = Constants.XERCES_PROPERTY_PREFIX;
    String propName = propPrefix + Constants.SCHEMA_LOCATION;
    fSchemaLoader.setProperty(propName, getProperty(propName));
    propName = propPrefix + Constants.SCHEMA_NONS_LOCATION;
    fSchemaLoader.setProperty(propName, getProperty(propName));
    propName = Constants.JAXP_PROPERTY_PREFIX+Constants.SCHEMA_SOURCE;
    fSchemaLoader.setProperty(propName, getProperty(propName));
    fSchemaLoader.setFeature(SCHEMA_FULL_CHECKING, getFeature(SCHEMA_FULL_CHECKING));

    // Should check whether the grammar with this namespace is already in
    // the grammar resolver. But since we don't know the target namespace
    // of the document here, we leave such check to XSDHandler
    SchemaGrammar grammar = (SchemaGrammar)fSchemaLoader.loadGrammar(is);
    // by default, hand it off to the grammar pool
    if (grammar != null) {
        fGrammarPool.cacheGrammars(XMLGrammarDescription.XML_SCHEMA,
                                  new Grammar[]{grammar});
    }

    return grammar;

}
 
Example #30
Source File: XMLDocumentParser.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Constructs a document parser using the specified symbol table and
 * grammar pool.
 */
public XMLDocumentParser(SymbolTable symbolTable,
                         XMLGrammarPool grammarPool) {
    super(new XIncludeAwareParserConfiguration());
    fConfiguration.setProperty(Constants.XERCES_PROPERTY_PREFIX+Constants.SYMBOL_TABLE_PROPERTY, symbolTable);
    fConfiguration.setProperty(Constants.XERCES_PROPERTY_PREFIX+Constants.XMLGRAMMAR_POOL_PROPERTY, grammarPool);
}